JUnit 5 is here
© Shutterstock / paikong
JUnit 5 is the result of approximately two years of work and now it’s finally here. Read on to find out what’s new about the new major version of the programmer-friendly testing framework for Java 8.
Now that the new major version is out, let’s see what’s new and exciting.
— JUnit Team (@junitteam) September 10, 2017
JUnit 5: Highlights
According to the JUnit 5 user guide, this major version consists of several different modules from three different sub-projects.
JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage
The JUnit Platform serves as a foundation for launching testing frameworks on the JVM. It also defines the
TestEngine API for developing a testing framework that runs on the platform. Furthermore, the platform provides a Console Launcher to launch the platform from the command line and build plugins for Gradle and Maven as well as a JUnit 4 based Runner for running any
TestEngine on the platform.
JUnit Jupiter is the combination of the new programming model and extension model for writing tests and extensions in JUnit 5. The Jupiter sub-project provides a
TestEngine for running Jupiter based tests on the platform.
JUnit Vintage provides a
TestEngine for running JUnit 3 and JUnit 4 based tests on the platform.
Even though this new version requires Java 8 (or higher) at runtime, you can still test code which has been compiled with previous versions of the JDK.
“With JUnit 4 a lot of stuff that was originally added as an internal construct only got used by external extension writers and tool builders. That made changing JUnit 4 especially difficult and sometimes impossible,” the team wrote in the user guide.
Therefore, one of the biggest goals of this version is to enhance maintainters’ capabilities to evolve JUnit even though it is being used in many projects — which is why JUnit 5 introduced a defined lifecycle for all publicly available interfaces, classes, and methods.
The first General Availability Release was announced on September 10, 2017.
For more information about JUnit 5, read the user guide.