Skip to content

JeffFaer/lambda-matcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lambda-matcher

Create Hamcrest Matchers with Java 8 method references and lambdas.

Maven Central

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);
  }

About

Create Hamcrest Matchers with method references and lambdas.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages