An adapter to use Hamcrest matchers as AssertJ conditions

Following on from yesterday’s post on AssertJ, here’s a tiny github repo that I put together with some utilities for AssertJ.

The first is the script mentioned yesterday, tidied up a little and renamed.

The second is a little adapter class that allows you to use Hamcrest Matchers as AssertJ Conditions.  So, if you have some really complex Hamcrest matcher stuff, you can migrate it easily:

java final String actual = "how now brown cow"; assertThat(actual).is(matchedBy(Matchers.containsString("now brown"))); `

The adapter is provided by that “matchedBy” factory method.  But the github repo has a full README for details.

April 18, 2015 assertj hamcrest java junit tdd