Running tests in JUnit 5
At the time of writing, Jupiter tests can be executed in several ways:
- Using a build tool: Maven (implemented in the module
junit-plaform-surefire-provider
) or Gradle (implemented in the modulejunit-platform-gradle-plugin
). - Using the Console Launcher: A command-line Java application that allows to launch the JUnit Platform from the console.
- Using an IDE: IntelliJ (since version 2016.2) and Eclipse (since version 4.7, Oxygen).
As we are going to discover, and due to the modular architecture of JUnit 5, we need to include three dependencies in our projects: one for the Test API (to implement tests), an other for the Test Engine (to run tests), and the last one of the Test Launcher (to discover tests).
Jupiter tests with Maven
In order to run Jupiter tests within a Maven project, we need to configure the pom.xml
file properly. First of all, we need to include the junit-jupiter-api
module as a dependency. This is needed to write our test, and typically with test scope:
<...