Skip to content

Nested tests in JUnit 6 cause JUnit 5 error #1838

@MaddyGuthridge

Description

@MaddyGuthridge

After having my previous report in #1837 unceremoniously and erroneously closed by an AI with no human review, I am opening a new issue to report this bug.

When I have a nested test declaration in a project which uses JUnit 6, attempting to run the test gives an error:

Cannot find org.junit.platform.commons.annotation.Testable on project build path. JUnit 5 tests can only be run if JUnit 5 is on the build path.

As per my project's configuration, we are using JUnit 6, so it is self-evident that JUnit 5 would not be present on the build path. Even if it were present, using it on a project that required JUnit 6 would be incorrect.

Relevant snippet from build.gradle:

dependencies {
    // Use JUnit Jupiter for testing.
    testImplementation 'org.junit.jupiter:junit-jupiter:6.0.1'
    //                                                  ^^^^^
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

Reproducing

A full reproduction can be found in this repository.

System info

  • NixOS 25.11
  • VS Code 1.109.2
  • Test Runner for Java 0.44.0
  • Gradle 9.2.0
  • Java 21

This issue has also been reproduced on the systems of many of our students.

Notes

  • This issue is not a duplicate, despite the AI's hallucinations.
  • The AI's suggested fix in the previous issue did not work to resolve the issue.
  • This issue affects me, and hundreds of other students in the course I teach.
  • Having an AI automatically close my issue without human review with no way for me to reopen the issue if the AI spits out BS that does not help is an insult to my intelligence.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions