IsSimilar extends BaseMatcher<CharSequence> { @Override public void describeTo(final Description description) { description.appendText("has max Levenshtein distance ").appendValue(maxDistance) .appendText(" from ").appendValue(target); } IsSimilar(final CharSequence target, final int levenshteinDistance); static Matcher<CharSequence> similar(final CharSequence target, final int levenshteinDistance); @Override boolean matches(final Object arg); @Override void describeTo(final Description description);  }
@Test public void testDescribeTo() throws Exception { final int distance = 0; assertIsDescribedTo(String.format("has max Levenshtein distance <%d> from \"%s\"", distance, comparison), IsSimilar.similar(comparison, distance)); }