JUnit addons

JUnit-addons is a useful library that extends JUnit asserting features. To name a few:

junitx.framework.ArrayAssert: If you’ve written test cases long enough you’ll know that assertEquals won’t work on arrays, and you’ll repeatedly write a loop to assert so. This class takes care of it all.

junitx.util.PrivateAccessor: I’ve always written utility classes to help me set private fields when mocking test objects. Looks like I’m not the only one with the problem.

junitx.framework.Assert.assertNotEquals(): Might be useful in certain cases. Not really recommended because you really want to match the value you’re asserting. It’s too easy to pass a NotEquals() test.

Leave a Reply