IsNot extends BaseMatcher<T> { public static <T> Matcher<T> not(Matcher<T> matcher) { return new IsNot<T>(matcher); } IsNot(Matcher<T> matcher); @Override boolean matches(Object arg); @Override void describeTo(Description description); static Matcher<T> not(Matcher<T> matcher); static Matcher<T> not(T value);  }
@Test public void copesWithNullsAndUnknownTypes() { Matcher<String> matcher = not("something"); assertNullSafe(matcher); assertUnknownTypeSafe(matcher); }
@Test public void evaluatesToTheTheLogicalNegationOfAnotherMatcher() { final Matcher<String> matcher = not(equalTo("A")); assertMatches(matcher, "B"); assertDoesNotMatch(matcher, "A"); }
@Test public void providesConvenientShortcutForNotEqualTo() { final Matcher<String> matcher = not("A"); assertMatches(matcher, "B"); assertDoesNotMatch(matcher, "A"); }
@Test public void usesDescriptionOfNegatedMatcherWithPrefix() { assertDescription("not an instance of java.lang.String", not(instanceOf(String.class))); assertDescription("not \"A\"", not("A")); }