NUnit and MSTest both have an assertion method named AreEqual and it does what you'd expect: checks whether or not two values are equal. In both unit testing frameworks, the method signature looks like this:
public static void AreEqual<T>(T expected, T actual)
Notice that the first parameter is named "expected" and the second parameter is named "actual", not the other way around. For all that is holy and good, do not switch these around. Doing so can lead to unexpected test results: a test will fail (maybe not unexpected) with an output that shows the opposite of what you expect (that's the unexpected part), and then you're left wondering why and it's all because you didn't pay attention to details and switched the parameters.
So please get it right, and while you're at it, I'm gonna need you to send in your TPS report.
Print | posted on Thursday, December 20, 2007 12:34 PM