Whenever I run my projects JUnit test (using JUnit 5 with Java 9 and Eclipse Oxygen 1.a) I encounter the problem that eclipse can\'t find any tests.
I'm using:
Spring Tool Suite 4 Version: 4.4.2.RELEASE Build Id: 201911201053 Java version: 1.8.0_191
and the message displayed is No tests found with test runner 'JUnit5'
what worked for me was the configuration below
<properties>
<java.version>1.8</java.version>
<junit-jupiter.version>5.5.2</junit-jupiter.version>
<junit-platform.version>1.5.2</junit-platform.version>
</properties>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
SIMPLE FIX: (Add JUnit 5 Library)
INSTRUCTIONS:
When I change my jupiter api version into latest one, it was solved. Meanwhile, my eclipse and other eclipse extensions ide's (such as STS) is getting build path error. For every maven update, ide forces me to set the JRE System Library.
In my case, the problem was myself and no IDE like Eclipse. I've imported the JUnit 4 Test class.
So do NOT import this one:
import org.junit.Test // JUnit 4
But DO import that one:
import org.junit.jupiter.api.Test // JUnit 5
I also faced the same issue you just need to add the library , Junit Library is already provided along with Eclipse so you just need to follow below
Build Path > Configure Build Path > library > Add library > JUnit > Next > finish
It works for me
It may cause by the version of junit-platform-launcher / junit-platform-runner.
1.1.0 does not work
1.4.1 works in my setup.
I think this is a bug in eclipse as it is working with higher version libraries of junit and not other version.
This resolved my issue. The other resolution looked less feasible or risky to me. Thanks.