lambda-matcher
Create Hamcrest Matchers with Java 8 method references and lambdas.
An alternative to FeatureMatcher. Instead of implementing a new class, just call one of the static factory methods in LambdaMatcher. For instance, if you wanted to create a matcher on a Throwable's message:
Throwable t = new Throwable("foobar");
@Test
public void test() {
assertThat(t, hasMessage(containsString("foo")));
}
public static Matcher<? super Throwable> hasMessage(Matcher<? super String> matcher) {
return LambdaMatcher.createMatcher(Throwable::getMessage, matcher);
}