The JEE ecosystem is rather well equiped with a huge galaxy of tools. I offer you here my list of favorite tools.
The collection of testing tools is amazingly vast and I discover some almost every months.
Unit testing :
Sometimes I have been using https://github.com/Pragmatists/JUnitParams to setup parameterized test easily.
And http://labs.carrotsearch.com/junit-benchmarks-tutorial.html to setup simple JUnit micro-benchmarks (yeah I know it exists JMH).
Don’t miss the new version 5 of JUnit, there are many cool features!
Here also check the new features coming with Mockito 2.0, the fluent BDD interface is great.
You cannot avoid Hamcrest to implement a little bit more evolved assertions and get better debugging messages.
I dream to have an equivalent version of Chai for Java 🙁
Many frameworks are available. I often suggest to give a try to write your unit tests in a language different from Java.
First you may have the surprise how much your productivity will increase, and some test frameworks are just great.
Documentation is there :
Looks great isn’t it ? It provides an canevas to write your tests and Groovy langage is considerably shortening your code.
There are plenty of other frameworks :
JGiven framework is interesting since it provides a fluent API to write your tests.
As a daily practice, writing tests can become boring or tidious leading to a huge amount of duplicated codes. JGiven is offering to generate for you a fluent API.
The user guide is there.
You should definitely have a look to this extension at the expense of a slower startup time for your tests.
JNario is an interesting project however I do really hate Eclipse technologies as XTend, it tends not be working at all outside Eclipse. A definitely no-go for me.
I become lazier with age and experience to produce stubs for my unit tests. I recommend to think as soon as possible how to collect your DTO and other value objects directly from your test environments and store them into your project.
At least you will have true test data to test your programs.
If you have forgotten to capture these data, these two libraries may help you :
- Random beans : take any Java class, initialize it and fill it with random data
- JFairy provides random set of data for common information (Creditcard,IBAN, Name, Lastname, Firstname etc
Other interesting tools
I have tried a few tools to generate unit tests :
- CodePro is an Eclipse plugin from a society acquired by Google. Their tool ha been open-sourced since.
- Evosuite : generate a suite of unit tests for a method. Check the screencast for morei nformations
- Cucumber : https://cucumber.io/docs/reference/jvm
- DBUnit : Write easier tests using your database.
- HavaRunner : JUnit extension to execute concurrent test inside a same class
- Randoop : Randomly generated tests.
- Mock mail smtp server : useful library when you are coding unit tests for mail functionalities.
- Java test frameworks : https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#Java