I wonder same. The API of Assert is not very symmetric; for testing whether objects are the same, it provides assertSame
and assertNotSame
.
Of course, it is not too long to write:
assertFalse(foo.equals(bar));
With such an assertion, the only informative part of the output is unfortunately the name of the test method, so descriptive message should be formed separately:
String msg = "Expected <" + foo + "> to be unequal to <" + bar +">";
assertFalse(msg, foo.equals(bar));
That is of course so tedious, that it is better to roll your own assertNotEqual
. Luckily in future it will maybe be part of the JUnit: JUnit issue 22