开发者

Is the order of the two parameters in Assert.AreEqual(expected, actual) important?

I wonder if the order is important?开发者_C百科 What do you think?


Well, primarily it's important so that if the test fails, the failure message is correct. Otherwise you'll be chasing your tail trying to work out why the expected value looks wrong but the actual value looks right.


It's needed so you have readable failure messages. If your tests fails, you'll get something like

Assert.Equal failed: value should have been X, but was Y

it would be confusing if X and Y were switched

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜