Posted By:
brian_surratt
Posted On:
Friday, April 5, 2002 10:49 AM
Is there a consensus on the best way to phrase the messages used in JUnit asserts? I'm inclined to make the message describe the failure condition. For example: assertNotNull("the object was null", theObject); assertEquals("the number did not equal 3", 3, theNumber); This would make the failure more meaningful when it is displayed. However, the concept of an assertion is that you're saying "Hey, this should be true". This suggests that following might be more correct: assertNotNull("the object was not null", theObject); assertEquals("the number equals 3", 3, theNumber);
More>>
Is there a consensus on the best way to phrase the messages used in JUnit asserts? I'm inclined to make the message describe the failure condition. For example:
assertNotNull("the object was null", theObject);
assertEquals("the number did not equal 3", 3, theNumber);
This would make the failure more meaningful when it is displayed.
However, the concept of an assertion is that you're saying "Hey, this should be true". This suggests that following might be more correct:
assertNotNull("the object was not null", theObject);
assertEquals("the number equals 3", 3, theNumber);
I browsed the JUnit home page and could not find anything to provide guidance.
Thanks,
Brian
<<Less