IsBetweenUpperBoundInclusive extends TypeSafeMatcher<T> { @Override protected void describeMismatchSafely(final T item, final Description mismatchDescription) { mismatchDescription.appendValue(item).appendText(" is not between ").appendValue(from) .appendText(" excluded and ").appendValue(to).appendText(" included"); } IsBetweenUpperBoundInclusive(final T from, final T to); static Matcher<T> betweenUpperBoundInclusive(final T from, final T to); @Override void describeTo(final Description description);  }
@Test public void testDescribeMismatchSafely() throws Exception { assertHasMismatchDescription("<9> is not between <10> excluded and <12> included", isBetweenUpperBoundInclusiveMatcher, 9); assertHasMismatchDescription("<10> is not between <10> excluded and <12> included", isBetweenUpperBoundInclusiveMatcher, 10); }