New to unit testing, and am a little confused on what the difference between Assert.False(true)
vs Assert.True(false)
would be?
Could someone explain how these are different?
Both are guaranteed to fail.
Assert.False
passes if the argument evaluates to false
, which true
does not.
Assert.True
passes if the argument evaluates to true
, which false
does not.
The difference is what condition makes them pass, but when passing a constant as your code does; it just means a guaranteed failure. They also have different semantic meaning (for obvious reasons).
Both Assert.True(false)
and Assert.False(true)
will cause the test to fail. They both can be read like "Make sure this value is true, if it's not then fail." and "Make sure this value is false, if it's not then fail." respectively. So whatever the condition/value in your assertion is, it must evaluate to the respective value or the test will fail.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.