Reputation: 63
I'm using Maven to build a Spring boot project.
When I set Junit jupiter dependencies like this
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.5.1</version>
<scope>test</scope>
</dependency>
I got the error
juil. 23, 2019 10:47:42 PM org.junit.platform.launcher.core.DefaultLauncher handleThrowable AVERTISSEMENT: TestEngine with ID 'junit-jupiter' failed to discover tests java.lang.NoClassDefFoundError: org/junit/platform/engine/support/discovery/SelectorResolver
But when I set dependencies using aggregator, tests are executed normally.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.5.1</version>
<scope>test</scope>
</dependency>
So what's are the difference between this two ?
Upvotes: 3
Views: 2247
Reputation: 1332
You are missing junit-platform-launcher
artifact. See official JUnit 5 User Guide:
JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage
You should add this to your pom.xml
:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.5.2</version>
<scope>test</scope>
</dependency>
Upvotes: 2