Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Converting from Hamcrest to AssertJ

DZone's Guide to

Converting from Hamcrest to AssertJ

· Java Zone ·
Free Resource

Verify, standardize, and correct the Big 4 + more– name, email, phone and global addresses – try our Data Quality APIs now at Melissa Developer Portal!

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!

Developers! Quickly and easily gain access to the tools and information you need! Explore, test and combine our data quality APIs at Melissa Developer Portal – home to tools that save time and boost revenue. 

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}