JUnit’s method parameter ordering makes sense to me.

Cedric writes in it’s JUnit wish list that the ordering of parameters of the assertXXX methods was not optimal.

He writes:

When I read the code, I want to know what is being tested first, not what will be printed if the test fails.

I think Cedric misses the point that the message you pass to the assert method should of course tell the developer “what is being tested”, not that something failed.

The examples Cedric provides show perfectly how not to write a test: assertTrue(“Test failed”, n == 42) tells you nothing, more appropriate was assertTrue(“The Ultimate answer to Life, the Universe and Everything must be 42”, n == 42), e.g.


{ Comments are closed! }