hamcrest asserthat true code example
Example 1: error: The method assertThat(T, Matcher) in the type MatcherAssert is not applicable for the arguments (List, Matcher>)
assertEquals(expected, actual);
assertThat(actual, is(equalTo(expected)));
assertNotEquals(expected, actual)
assertThat(actual, is(not(equalTo(expected))));
Example 2: error: The method assertThat(T, Matcher) in the type MatcherAssert is not applicable for the arguments (List, Matcher>)
assertTrue(result instanceof String);
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertTrue(Assert.java:52)
assertEquals(String.class, result.getClass());
java.lang.NullPointerException
at com.vogella.hamcrest.HamcrestTest.test(HamcrestTest.java:30)
assertThat(result, instanceOf(String.class));
java.lang.AssertionError:
Expected: an instance of java.lang.String
but: null
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)