Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using not operation in hamcrest

Tags:

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?

like image 965
Ankit Dhingra Avatar asked Apr 27 '11 22:04

Ankit Dhingra


2 Answers

You're almost there:

assertThat(2 , is(not(3)));
like image 51
skaffman Avatar answered Oct 25 '22 20:10

skaffman


Be sure you import it:

import static org.hamcrest.CoreMatchers.not;
like image 45
anfilbiblio Avatar answered Oct 25 '22 18:10

anfilbiblio