InfoQ reports that JUnit 4.4 has been released. I have not had a chance to download it and try it out, but it looks like it has added a very good and useful feature, assertThat.

This is a very welcome addition. For a long time I have actually been using RMock in my TestCases solely for the assertThat method that it provides. For example, let’s say I want to assert that a string contains “foo” or “bar”, I can do this in RMock like this:


assertThat(result, is.containing("foobar").or( is.containing("bar") ));

Which is better than that assertTrue nonsense with a little bit of code jammed inside it to return true or false. JUnit4.4 now does something similar:


assertThat(result, either(containsString("foo")).or(containsString("bar")));

Cool stuff… I’ll have to start using this new version. :)

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!