simple I thought
Assert.assertThat(
iterator.next(),
Matchers.either(Matchers.nullValue()).or(
Matchers.instanceOf(Double.class)));
So I'd like to ensre next() returns one of two, NULL or instance of a Double. Sth like
Assert.assertTrue(next == null || next instanceof Double);
Test run (assertThat
) outcomes in...
java.lang.NoSuchMethodError: org.hamcrest.Matcher.describeMismatch(Ljava/lang/Object;Lorg/hamcrest/Description;)V
at org.hamcrest.core.CombinableMatcher.matchesSafely(CombinableMatcher.java:17)
at org.hamcrest.TypeSafeDiagnosingMatcher.matches(TypeSafeDiagnosingMatcher.java:55)
at org.junit.Assert.assertThat(Assert.java:772)
at org.junit.Assert.assertThat(Assert.java:738
Why? And how to fix?
EDIT
You were right, there was a collision with hamcrest lib comming from Mockito. I have it fixed. Ther's no error but the assertion fails strangely, take a look:
java.lang.AssertionError:
Expected: (null or an instance of java.lang.Double)
got: null
at org.junit.Assert.assertThat(Assert.java:780)
at org.junit.Assert.assertThat(Assert.java:738)
Null was expected, got null and a test is failing.