JUnit5 is the next generation of JUnit. The goal is to create an up-to-date foundation for developer-side testing on the JVM. This includes focusing on Java 8 and above, as well as enabling many different styles of testing.
JUnit 5 is split into three sub-projects: Jupiter, Vintage, and Platform.
They communicate via published APIs, which allows tools and libraries to inject customized behavior. Then, each sub-project is split into several artifacts to separate concerns and guarantee maintainability.
JUnit Vintage:
Implements an engine that allows to run tests written in JUnit 3 and 4 with JUnit 5.
JUnit Jupiter is the combination of the new programming model and extension model for writing tests and extensions in JUnit 5.
Required Dependencies:
The junit-jupiter-api (version 5.4.2):This dependency provides the public API for writing tests and extensions.
The junit-jupiter-engine (version 5.4.2):This dependency contains the implementation of the JUnit Jupiter test engine that runs our unit tests.
Configuring the Maven Surefire Plugin:
build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
</plugins>
</build>
Note: First, if we want to use the native JUnit 5 support of the Maven Surefire Plugin, we must ensure that at least one test engine implementation is found from the classpath.
That’s why we added the junit-jupiter-engine dependency to the test scope.
No comments:
Post a Comment