days
1
4
hours
0
8
minutes
4
3
seconds
3
5
search
Java 9 & Java EE 8: They are finally here!

JUnit 5 is here

Gabriela Motroc
JUnit 5

© 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.

Nicolai Parlog, the author of CodeFX wrote in an article published last year that JUnit 5 has “the potential to redefine testing on the JVM.”

Now that the new major version is out, let’s see what’s new and exciting.

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.

SEE ALSO: JUnit 5 — Next generation testing on the JVM

API evolution

“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

asap

Author
Gabriela Motroc
Gabriela Motroc is an online editor for JAXenter.com. Before working at S&S Media she studied International Communication Management at The Hague University of Applied Sciences.

Comments
comments powered by Disqus