Reputation: 41
First time posting! I've tried looking through all the other posts regarding surefire issues without any avail, so any help would be greatly appreciated.
I am currently trying to deal with the "junit-platform-surefire-provider has been deprecated" warning in my project. Version 2.22.2 of surefire is being used, where all of the junit jupiter tests in our project are currently found.
WARNING: The junit-platform-surefire-provider has been deprecated and is scheduled to be removed in JUnit Platform 1.4. Please use the built-in support in Maven Surefire >= 2.22.0 instead. https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven
Test results with 55 tests found
The issue arises when I try to remove the junit-platform-surefire-provider and jupiter-engine dependencies from within the plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
This provider is going to be deprecated and I am trying to get rid of it. I followed the documentation at https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven in order to try and use the built in support in Maven Surefire. In addition to removing those two dependencies, I added the following two dependencies to my section on my POM file.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
Once I have done this, the build will complete, but it no longer finds any tests.
Test Results with ZERO tests found
Is there something that I'm missing?
Upvotes: 4
Views: 7652
Reputation: 21
Update
Had same issue on
Added on pom.xml
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.7.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.0</version>
</dependency>
<!--.... other dependencies -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<!--.... other plugins -->
</plugins>
</build>
Works fine and run all my test
Upvotes: 2
Reputation: 457
I had a similar problem, I needed to run Junit 4.12 tests a long with Junit 5. After I added the Junit 5 tests i got the next error:
[INFO] T E S T S 16:28:24 [INFO]
-------------------------------------------------------
16:28:26 [INFO]
16:28:26 [INFO] Results:
16:28:26 [INFO]
16:28:26 [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
16:28:26 [INFO]
16:28:26 [INFO]
------------------------------------------------------------------------
16:28:26 [INFO] BUILD SUCCESS
16:28:26 [INFO]
------------------------------------------------------------------------
I read that adding
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.3.2</version>
</dependency>
can fix my problem, but when I tried to run my tests I got next message
[INFO] T E S T S
16:12:57 [INFO] -------------------------------------------------------
16:12:58
16:12:58 +-------------------------------------------------------------------------------+
16:12:58 | WARNING: |
16:12:58 | The junit-platform-surefire-provider has been deprecated and is scheduled to |
16:12:58 | be removed in JUnit Platform 1.4. Please use the built-in support in Maven |
16:12:58 | Surefire >= 2.22.0 instead. |
16:12:58 | » https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven |
16:12:58 +-------------------------------------------------------------------------------+
16:12:58
finally next pom settings fixed it for me:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
.... More code here non relevant
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.5.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
</dependency>
.... More code here non relevant
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<dependenciesToScan>
<dependency>${group.id}:${test.project.name}</dependency>
</dependenciesToScan>
<encoding>UTF-8</encoding>
<inputEncoding>UTF-8</inputEncoding>
<outputEncoding>UTF-8</outputEncoding>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
Now when I tried to run Junit 4.12 tests they were found, and executed.
I have noticed some problem with log4j logs, which only showed exceptions stack traces. Also Junit5 stopped working. Hence after more testing my final version of the pom file.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
.... More code here non relevant
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.5.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
.... More code here non relevant
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<dependenciesToScan>
<dependency>${group.id}:${test.project.name}</dependency>
</dependenciesToScan>
<encoding>UTF-8</encoding>
<inputEncoding>UTF-8</inputEncoding>
<outputEncoding>UTF-8</outputEncoding>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
Upvotes: 1