Over a million developers have joined DZone.

An Adapter to use Hamcrest Matchers as AssertJ Conditions

DZone's Guide to

An Adapter to use Hamcrest Matchers as AssertJ Conditions

· Java Zone
Free Resource

Make it happen: rapid app development on Kubernetes as a managed service.

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:

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.

Tutorial: WordPress as distributed microservices on Kubernetes.


Published at DZone with permission of Dan Haywood, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}