Can't find tests (JUnit 5)


When I attempt to run an entire folder of unit tests, I am told that "No tests were found". I am told that "Tests were not found in module [OMITTED MODULE NAME]. Use module [OTHER OMITTED MODULE NAME] instead." I have changed and applied the classpath to the specified module under Run -> Debug Configurations, but I every time I run the folder again it reverts to the prior classpath.

When I attempt to run a single unit test file, I get the following stack trace:

Feb 06, 2018 2:01:43 PM org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID 'junit-jupiter' failed to discover tests
org.junit.platform.commons.util.PreconditionViolationException: Could not load class with name: [OMITTED JAVA FILE NAME]
at org.junit.platform.engine.discovery.ClassSelector.lambda$getJavaClass$0(
at java.util.Optional.orElseThrow(
at org.junit.platform.engine.discovery.ClassSelector.getJavaClass(
at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.lambda$resolveSelectors$2(
at java.util.ArrayList.forEach(
at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(
at org.junit.jupiter.engine.JupiterTestEngine.resolveDiscoveryRequest(
at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(
at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(
at com.intellij.rt.execution.junit.JUnitStarter.main(


As far as I can tell, my setup is identical to that of my coworkers, who are not having any issues.


IntelliJ IDEA version: 3.4

OS: Mac OS X

Relevant Gradle dependencies:

testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.2'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.0.2'
Comment actions Permalink

Please try File | Invalidate Caches | Invalidate and Restart, then rebuild the project.

If the issue persists, please provide the sample project to reproduce.

Comment actions Permalink

I've tried your suggestion, to no avail. Unfortunately, I'm not legally allowed to provide the project in question. Do you have any other ideas?

Comment actions Permalink

You probably don't need this dependency:

testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.0.2

since IntelliJ IDEA 2017.3.4 comes with the up to date JUnit version bundled.


> // Only needed to run tests in a version of IntelliJ IDEA that bundles an older version

Fix the dependencies, delete .idea directory, reimport the project from Gradle.

Comment actions Permalink

It turns out I was using a different JDK version from my teammates. I downgraded to what they were using and it seems to work now.

Comment actions Permalink

I have same problem. It's seems it doesn't work with JDK 10.

Comment actions Permalink

I have similar issues with Java 11 (if that is, in fact, the root cause).

Comment actions Permalink

This problem appeared in a project that stored its junit-dependencies explicitly (no maven or whatsoever), and somehow the module dependencies were removed and replaced by the IDE's bundled JUnit 5. I removed that one and restored the dependencies on the project's JARs of these.

Comment actions Permalink

Please create an issue at YouTrack: with project sample attached. Thank you.

Comment actions Permalink

Found reason o

Idea will download specific versions of JUnit platform dependencies specified  in mvane/gradle.




Please sign in to leave a comment.