What JUnit command i should use to check that, the expected is not equal to the actual.

Nikita Kozlovsky :

So the question is: what JUnit command i should use to check that the expected is not equal to the actual. For example i use assertEquals like this

assertEquals(tr1.detectTriangle(), tr1.TR_EQUILATERAL);

So here expected variable is 2 but actual is 1 and test fails. What command i should use to make this test passed?

GhostCat salutes Monica C. :

Of course, there is the simple assertNotEquals(), but I typically suggest to use the one and only assert you really need: assertThat!

assertThat(actual, is(expected));

or, in your case:

assertThat(actual, not(expected));

Where is() and not() are hamcrest matchers that do exactly what their names imply.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=91847&siteId=1