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'

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

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


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?


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.


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.


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


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


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.


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


Found reason o

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




I resolved the issue excluded the junit-jupiter-engine


Why would I want to exclude `junit-jupiter-engine`, which is required for my maven build to run, so that I can run tests directly in the IDE?

This is fundamentally broken.


Hello Dave,

Please share the sample project where you experience the issue at YouTrack:

Thank you 


Hi Olga,

Unfortunately I can't - it is proprietary and protected by NDA. And I don't have time to experiment with creating an MRE.

Honestly though, the details of my project should not matter. Running a correctly defined JUnit test from the IDE invoker should just work regardless of what build framework I use or what test dependencies I have for that framework.


Dave, please clarify what version of Junit framework is used in your case? I've checked the sample project with Juni5 tests with the dependencies that you've provided and the tests are successfully run. 

Here is the code sample:

package pack;

public class Sample {
public String foo() {
return "aaa";

package pack;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

class SampleTest {
public void fooTest() {
Assertions.assertEquals(new Sample().foo(), "aaa");


The version of IntelliJ IDEA used:

If possible can you please check the same one. 

Thank you 



Hi Olga,

I am using Junit5. I didn’t mention my dependencies, but the project is built using maven and i am using the Junit5 Jupiter framework. IntelliJ IDEA version is the latest Ultimate GA build.

Did you try running tests for the entire test class or just the fooTest method?

If i try to run a single test method it works fine. But if I try to run tests for a test class it fails to find any tests.

This is annoying for test classes with dozens of test methods.

The same tests are detected and run by the maven runner. But running the entire maven build, which takes minutes, is not practical for just testing one class i have changed in a TDD loop.



The test is run for me when I run it from any level: package, module, class. Please see the issue created:

my sample project is attached to the issue. Is the problem reproduced for you with it? Thank you


Just a note to anyone coming across this more recently that the reason Yurii Ch's solution above may work for them is if their project actually has older (Junit 4) dependencies in it, like mine. I upgraded my project to Java 11 and ran into the same problem, because another dependency was pulling in junit-jupiter-api and I think IntelliJ may be interpreting that to mean that my project should build tests with Junit 5. Excluding junit-jupiter-api fixed it.


I got it fixed in Gradle 8 by providing suite configuration with JUnitJupiter, however, Idea (IntelliJ IDEA 2023.2.2 (Ultimate Edition)) still see it as a gradle task, not Junit.

dependencies {
  testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0" }

testing {
    suites {
        val test by getting(JvmTestSuite::class) {



Please sign in to leave a comment.