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