Over a million developers have joined DZone.

Consider assertThat() in place of assertEquals()

DZone's Guide to

Consider assertThat() in place of assertEquals()

· Java Zone
Free Resource

Get the Edge with a Professional Java IDE. 30-day free trial.


JUnit 4.4 added a new assertion mechanism with the method assertThat(). Have a look and consider using it in place of assertEquals().

assertThat(result, is(42));
assertThat(output, containsString("foo"));

Get the Java IDE that understands code & makes developing enjoyable. Level up your code with IntelliJ IDEA. Download the free trial.


Published at DZone with permission of Mike Christianson, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}