Using not operation in hamcrest

Ankit Dhingra picture Ankit Dhingra · Apr 28, 2011 · Viewed 7k times · Source

I was recently trying to assert the inequality in one of the test. However I wasnt able to find the appropriate matcher in hamcrest. What I ideally want to do is something like.

assertThat(2 , isNot(3));

Is there any way to do it?

Answer

skaffman picture skaffman · Apr 28, 2011

You're almost there:

assertThat(2 , is(not(3)));