Sep 272012
 

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

  3 Responses to “Consider assertThat() in place of assertEquals()”

  1. [...] Consider assertThat() in place of assertEquals() (CodeAwesome) [...]

  2. Why? I cant understand why i supposed to leave the AssertEquals instead AssertThat. Can you give a explanation? Thanks!

  3. @Ramiro have a look at the link titled “JUnit 4.4 added a new assertion mechanism” for further, interesting details.

Leave a Reply