Over a million developers have joined DZone.

Converting from Hamcrest to AssertJ

· Java Zone

Discover how AppDynamics steps in to upgrade your performance game and prevent your enterprise from these top 10 Java performance problems, brought to you in partnership with AppDynamics.

Don’t quite know how I missed it all these years, but I only recently discovered AssertJ.  So I’ve started to use it in some of the Isis Addons example apps, for example the todoapp.

I had a look to see if there were any scripts to convert the Hamcrest assertThat assertions into corresponding AssertJ ones, but only turned up Joel’s script that works on vanilla JUnit assertEquals(…) assertions.  So I spent a bit of time updating it to support Hamcrest style assertions.  (I also refactored it so that it doesn’t rely on sed -i which seems to be pretty broken on Windows).

You’ll find a copy of my updated script in the todoapp’s repo.  I’ve left in (though commented out) the original assertions for assertEquals etc; should be easy enough to add in if you want.

Please feel free to pass around!

The Java Zone is brought to you in partnership with AppDynamics. AppDynamics helps you gain the fundamentals behind application performance, and implement best practices so you can proactively analyze and act on performance problems as they arise, and more specifically with your Java applications. Start a Free Trial.

Topics:

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

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

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

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

{{ parent.tldr }}

{{ parent.urlSource.name }}