I was shocked when something like:
assertThat(null, either(is(nullValue())).or(notNullValue()));
Failure:
java.lang.AssertionError: Expected: (is null or not null) but: was null at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20) at org.junit.Assert.assertThat(Assert.java:956) at org.junit.Assert.assertThat(Assert.java:923) at Demo.testName(Demo.java:12)
I do not think this use is very unusual (I'm actually trying to approve a null or empty card), and I did not find anything wrong with the Hamcrest source code ...
source share