Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ public static List<JavaTestItem> findTestPackagesAndTypes(List<Object> arguments
} else {
// 1. We suppose a class can only use one test framework
// 2. If more accurate kind is available, use it.
if (classItem.getTestKind() == TestKind.JUnit5 && kind == TestKind.JUnit) {
if ((classItem.getTestKind() == TestKind.JUnit5 ||
classItem.getTestKind() == TestKind.JUnit6) && kind == TestKind.JUnit) {
classItem.setTestKind(TestKind.JUnit);
}
}
Expand Down Expand Up @@ -386,7 +387,20 @@ private static void findTestItemsInTypeBinding(ITypeBinding typeBinding, JavaTes
final List<JavaTestItem> testMethods = new LinkedList<>();
searchers = searchers.stream().filter(s -> {
try {
return CoreTestSearchEngine.isAccessibleClass(type, s.getJdtTestKind());
if (CoreTestSearchEngine.isAccessibleClass(type, s.getJdtTestKind())) {
return true;
}
// For JUnit 6, Eclipse JDT's isAccessibleClass() only applies the
// relaxed @Nested class rules (non-static, non-public inner classes)
// when testKindId equals JUNIT5_TEST_KIND_ID. For JUNIT6_TEST_KIND_ID,
// it falls into the else branch requiring static + public, which
// incorrectly rejects valid @Nested test classes. Fall back to
// JUnit 5 accessibility check since JUnit 6 shares the same rules.
if (s.getTestKind() == TestKind.JUnit6) {
return CoreTestSearchEngine.isAccessibleClass(type,
org.eclipse.jdt.internal.junit.launcher.TestKindRegistry.JUNIT5_TEST_KIND_ID);
}
return false;
} catch (JavaModelException e) {
return false;
}
Expand Down Expand Up @@ -425,9 +439,15 @@ private static void findTestItemsInTypeBinding(ITypeBinding typeBinding, JavaTes
.build();
} else if (TestFrameworkUtils.JUNIT5_TEST_SEARCHER.isTestClass(type)) {
// to handle @Nested and @Testable classes
// Determine whether it's JUnit 6 or JUnit 5 based on project-level detection,
// since JUnit 6 extends JUnit 5 and both searchers match the same annotations.
final List<TestKind> projectKinds = TestKindProvider.getTestKindsFromCache(
type.getJavaProject());
final TestKind kind = projectKinds.contains(TestKind.JUnit6) ?
TestKind.JUnit6 : TestKind.JUnit5;
classItem = new JavaTestItemBuilder().setJavaElement(type)
.setLevel(TestLevel.CLASS)
.setKind(TestKind.JUnit5)
.setKind(kind)
.build();
}
}
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@
"contributes": {
"javaExtensions": [
"./server/com.microsoft.java.test.plugin-0.43.1.jar",
"./server/junit-jupiter-api_5.14.1.jar",
"./server/junit-jupiter-api_5.14.3.jar",
"./server/junit-jupiter-api_6.0.1.jar",
"./server/junit-jupiter-engine_5.14.1.jar",
"./server/junit-jupiter-engine_5.14.3.jar",
"./server/junit-jupiter-engine_6.0.1.jar",
"./server/junit-jupiter-migrationsupport_5.14.1.jar",
"./server/junit-jupiter-params_5.14.1.jar",
"./server/junit-jupiter-params_5.14.3.jar",
"./server/junit-jupiter-params_6.0.1.jar",
"./server/junit-platform-commons_1.14.1.jar",
"./server/junit-platform-commons_1.14.3.jar",
"./server/junit-platform-commons_6.0.1.jar",
"./server/junit-platform-engine_1.14.1.jar",
"./server/junit-platform-engine_1.14.3.jar",
"./server/junit-platform-engine_6.0.1.jar",
"./server/junit-platform-launcher_1.14.1.jar",
"./server/junit-platform-launcher_1.14.3.jar",
"./server/junit-platform-launcher_6.0.1.jar",
"./server/junit-platform-runner_1.14.1.jar",
"./server/junit-platform-suite-api_1.14.1.jar",
Expand Down
Loading