Skip to content
Advertisement

Gradle: Execution failed for task ‘:test’. > No tests found for given includes:

I try to run this single unit test of this open-source project on GitHub with IntelliJ.

JavaScript

The test class

JavaScript

The build.gradle

JavaScript

What I have tried

  • Updating to the newest JUnit

    testImplementation group: ‘org.junit.jupiter’, name: ‘junit-jupiter-api’, version: ‘5.9.1’

  • Adding this to my build.gradle file:

    test { useJUnitPlatform() }

The only workaround yet:

When I go to Settings -> Build-Tool -> Gradle and set the Test execution to “Run tests wit: IntelliJ IDEA” the tests are executed correctly.

Thanks

Advertisement

Answer

Problem is coming from the naming of the package which contains your test classes, DNAnalyzer, which does not really follow java naming conventions as it’s starts with/contains capital letters.

When executing single test case or test class, IntelliJ will delegate to Gradle by invoking test task with a specific filter, as follows ./gradlew :test --tests "DNAnalyzer.MainTest.mainClassshouldExist"

And in Gradle there is this issue : https://github.com/gradle/gradle/issues/20350 : “test –tests does not work with packages which contain capital letters”.

Try to move your test classes in another well-named package and you won’t have this issue.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement