In this Junit 5 maven article we will see how to configure Junit 5 in your Maven projects and how to run over maven commands and from your IDE like eclipse or STS (Spring tool suite).
Technologies used :
- Junit 5.5.2
- Maven 3
- Java 8
- Spring Tool Suite 3.9.8
Here is the simple maven project structure to demonstrate Junit 5 and Maven configuration.
junit-jupiter-engine maven dependency and
maven-surefire-plugin maven plugin to maven
pom.xml. Your pom.xml looks like below.
junit-jupiter-engine an api to create Junit 5 test cases.
A simple MathUtil.java class with basic methods to calculate math functions.
In your IDE, right click on your Junit 5 test case, go Run As and select Junit Test. Yoor test case execution will be started.
Junit 5 test case execution results in IDE:
mvn test maven command, the Maven
Surefire Plugin will scan and run all the Juint 5 test cases and you see the test cases execution results in console.