Reputation: 79
I have a Junit 5 suite class:
@Suite
@SelectClasses({
AAATests.class,
BBBTests.class
})
public class SanityTMTestsSuite5 {
}
I use this version:
<junit-jupiter.version>5.9.1</junit-jupiter.version>
surefire configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<includes>
<include>**/SanityTMTestsSuite*.java</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-suite</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
and another dependency outside the surefire definition:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>1.9.1</version>
<scope>test</scope>
</dependency>
When I execute mvn test
, I get
org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-platform-suite' failed to execute tests
Caused by: java.lang.NoSuchMethodError: 'org.junit.platform.launcher.core.LauncherDiscoveryResult org.junit.platform.launcher.core.LauncherDiscoveryResult.withRetainedEngines(java.util.function.Predicate)'
Upvotes: 0
Views: 6103
Reputation: 79
This configuration worked for me:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
<junit.version>1.9.1</junit.version>
<junit-jupiter.version>5.9.1</junit-jupiter.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<includes>
<include>**/SanityTMTestsSuite*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit-jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>${junit.version}</version>
</dependency>
<!--JUnit Jupiter Engine to depend on the JUnit4 engine and JUnit 4 API -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
</dependencies>
</project>
Upvotes: 0