The Mail Failsafe plugin won't find my JUnit 5 integration tests when I'm running the command mvn clean failsafe:integration-test
, although it can find the files.
I have the junit-jupiter-api
and junit-jupiter-engine
as test dependencies:
<properties>
<junit.jupiter.version>5.0.1</junit.jupiter.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
My integration tests are named correctly (following the **/*IT.java
, **/IT*.java
, or the **/*ITCase.java
that included by default by Failsafe and excluded by default by Surefire).
Is there any way that I can use JUnit 5 tests with Failsafe?
Note that from the JUnit 5 documentation :
junit-platform-surefire-provider
should be not used any longer :Additionally, you can also read in the
maven-surefire-plugin
documentation :So you have to specify this
test
dependency :And the
maven-failsafe-plugin
declaration could be as simple as :Edit: This answer was correct before
maven-failsafe-plugin:2.22.0
. See davidxxx's answer for the ideal and most up to date solution.The
maven-failsafe-plugin
currently doesn't support JUnit 5, out of the box.However, like with
maven-surefire-plugin
, you can run JUnit 5 tests with themaven-failsafe-plugin
by specifying the dependency on theorg.junit.platform:junit-platform-surefire-provider:1.0.1
with the earlier version of themaven-failsafe-plugin:2.19.1
.It doesn't work with the current version 2.20 of the failsafe (in the same way that the surefire has the error) due to an
OutOfMemory
error.See the below for an example of the configuration of the plugin:
You can find a full example of this working (and a failing one) on GitHub. To test that it works, you can run
mvn clean failsafe:integration-test
.