Skip to content

fix: fix junit 6 support#1840

Merged
wenytang-ms merged 2 commits intomainfrom
wenyt/fix6
Feb 26, 2026
Merged

fix: fix junit 6 support#1840
wenytang-ms merged 2 commits intomainfrom
wenyt/fix6

Conversation

@wenytang-ms
Copy link
Contributor

fix issue #1837

@wenytang-ms wenytang-ms marked this pull request as draft February 25, 2026 06:07
@wenytang-ms
Copy link
Contributor Author

Root Cause Analysis
The bug occurs in the findTestItemsInTypeBinding method of TestSearchUtils.java. This method is called when a test file is opened or changed (via the file watcher triggering findTestTypesAndMethods).

@wenytang-ms wenytang-ms marked this pull request as ready for review February 26, 2026 01:16
@wenytang-ms
Copy link
Contributor Author

OpenFile→ findTestTypesAndMethods()
→ TestKindProvider return [JUnit6]
→ Mapping to [JUnit6TestSearcher]
→ findTestItemsInTypeBinding()
→ isAccessibleClass filter JUnit6TestSearcher → searchers = []
→ No test cases found → into else
→ JUNIT5_TEST_SEARCHER.isTestClass() = true
→ testKind is hardcoded to JUnit5 ← BUG
→ test item take testKind=JUnit5 and set into dataCache

User run test cases → mapTestItemsByKind() from dataCache read testKind=JUnit5
→ testContext.kind = JUnit5
→ send JSON { testKind: 0 } to Java Extension
→ JUnitLaunchUtils Mapping to JUNIT5_LOADER
→ preLaunchCheck check JUnit 5 jar → not found → error

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes issue #1837 where JUnit 6 projects are incorrectly handled as JUnit 5 (leading to misleading “JUnit 5 … build path” errors), by improving JUnit 6 kind selection and discovery behavior.

Changes:

  • Updated bundled JUnit 5/Platform jar versions used by the extension.
  • Improved test kind resolution to correctly label items as JUnit 6 in cases where JUnit 5 and JUnit 6 annotations overlap.
  • Added a JDT accessibility-check fallback to avoid incorrectly rejecting valid JUnit 6 @Nested test classes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
package.json Updates the extension’s bundled JUnit jars used on the server side.
java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/util/TestSearchUtils.java Adjusts test discovery/kind assignment and accessibility checks for JUnit 6 compatibility.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wenytang-ms wenytang-ms merged commit 4c3c9db into main Feb 26, 2026
4 checks passed
@wenytang-ms wenytang-ms deleted the wenyt/fix6 branch February 26, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants