Question

I'm often creating custom assertion methods for my JUnit tests. eg:

public void assertArrays(String[] actual, String[] expected)

I was wondering if there were any decent third party libraries that can provide a wider range of assertions than what comes by default in JUnit.

Am using JUnit 4.

Was it helpful?

Solution

The one that has been around for ever is JUnit Addons.

OTHER TIPS

There is standard method for this purposes in JUnit4: assertArrayEquals

Google names their Asserts classes MoreAsserts. Here's one for one particular project and you can search for more, as most projects have their own and they are frequently open source'd.

Edit: Android has a pretty great one too, not sure if that source is available though.

I do not know of any such library. However, you might not really need this.

JUnit contains assertEquals for most value types of the JDK. For your own classes, you can simply override the equals() method, and use assertEquals(Object,Object).

This is what I usually do for my own classes. Works well, and a proper equals() method is useful anyway.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top