fix: reuse Jupiter finder for JUnit 6 discovery - #1910
Merged
Conversation
JUnit 5 and JUnit 6 share the same Jupiter discovery semantics. Reuse the established finder so non-static @nested classes receive the relaxed accessibility rules, while retaining the JUnit 6 kind for runtime selection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f7a1a4d1-b63f-438b-a255-54976b0f5a0b
There was a problem hiding this comment.
Pull request overview
This PR fixes JUnit 6 test discovery by reusing Eclipse JDT’s existing Jupiter (JUnit 5) test finder logic, eliminating a divergent JUnit 6 finder that applied stricter accessibility rules and incorrectly rejected valid @Nested classes.
Changes:
- Make
JUnit6TestSearcherinherit JUnit 5’s finder-based discovery behavior while still reportingTestKind.JUnit6/ JUnit 6 JDT kind IDs for runtime selection. - Remove the custom
JUnit6TestFinderimplementation. - Add regression coverage and a minimal workspace project for package-private, non-static
@NestedJUnit 6 classes.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/searcher/JUnit6TestSearcher.java | Drops custom finder usage and relies on inherited Jupiter discovery, keeping JUnit 6 kind identifiers. |
| java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/searcher/JUnit6TestFinder.java | Removes the divergent JUnit 6 finder implementation that caused incorrect accessibility filtering. |
| java-extension/com.microsoft.java.test.plugin/META-INF/MANIFEST.MF | Exports the searcher package to the test bundle via x-friends so the new test can access searchers. |
| java-extension/com.microsoft.java.test.plugin.test/src/com/microsoft/java/test/plugin/searcher/JUnit6TestSearcherTest.java | Adds a regression test validating discovery of a non-static, package-private @Nested class under JUnit 6. |
| java-extension/com.microsoft.java.test.plugin.test/projects/junit6-nested/src/test/java/example/NestedTests.java | Adds a sample JUnit 6 nested test case used by the regression test. |
| java-extension/com.microsoft.java.test.plugin.test/projects/junit6-nested/.project | Adds Eclipse project metadata for the regression test workspace project. |
| java-extension/com.microsoft.java.test.plugin.test/projects/junit6-nested/.classpath | Adds JDT classpath configuration using JUNIT_CONTAINER/6 for the regression test workspace project. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f7a1a4d1-b63f-438b-a255-54976b0f5a0b
wenyt (wenytang-ms)
marked this pull request as ready for review
August 17, 2026 06:58
Changyong Gong (chagong)
approved these changes
Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
JUnit6TestFinderimplementation@NestedJUnit 6 classesRoot cause
The custom JUnit 6 finder passed the JUnit 6 kind to
CoreTestSearchEngine.isAccessibleClass(). Eclipse JDT currently applies Jupiter's relaxed@Nestedaccessibility rules only throughJUnit5TestFinder, so valid nested classes could be rejected during container discovery and lazy loading.JUnit 5 and JUnit 6 share the same Jupiter discovery semantics. The JUnit 6 searcher now inherits
JUnit5TestFinderwhile retainingTestKind.JUnit6and the JUnit 6 JDT kind for runtime selection.Upstream alignment
JDT LS runs the JUnit support provided by Eclipse JDT's
org.eclipse.jdt.junit.corebundle. Eclipse JDT's merged JUnit 6 implementation explicitly shares the JUnit 5 finder while selecting a separate JUnit 6 runtime:finderClasstoJUnit5TestFinder, whileloaderPluginIdandloaderClasspoint to the JUnit 6 runtime:plugin.xmllines 112-117.JUnit5TestFinderfor JUnit 6":JUnit6TestFinderJupiterTest.javalines 49-54.JUnit5TestFinder:JUnit6TestFinderJupiterTest.javalines 116-122.JUnitJupiterTestFinderspecifically because it is reused for JUnit 6: eclipse-jdt.ui#2620.This PR follows that upstream separation: shared Jupiter discovery through
JUnit5TestFinder, with the JUnit 6 kind retained for launch/runtime selection.Validation
Addresses the test discovery and missing CodeLens portion of #1897. The individual-method launch hang still requires separate verification.