Skip to content
Merged
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
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/6"/>
<classpathentry kind="output" path="target/test-classes"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>junit6-nested</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package example;

import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

class NestedTests {

@Nested
class MemberTests {

@Test
void testNested() {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright (c) 2026 Microsoft Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Microsoft Corporation - initial API and implementation
*******************************************************************************/

package com.microsoft.java.test.plugin.searcher;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.List;
import java.util.Set;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.junit.launcher.TestKindRegistry;
import org.junit.Test;

import com.microsoft.java.test.plugin.AbstractProjectsManagerBasedTest;
import com.microsoft.java.test.plugin.model.TestKind;

public class JUnit6TestSearcherTest extends AbstractProjectsManagerBasedTest {

@Test
public void testFindNonStaticNestedTestClass() throws Exception {
final List<IProject> projects = importProjects("junit6-nested");
final IJavaProject javaProject = JavaCore.create(projects.get(0));
final IType outerType = javaProject.findType("example.NestedTests");
assertNotNull(outerType);

final IType nestedType = outerType.getType("MemberTests");
assertTrue(nestedType.exists());

final JUnit6TestSearcher searcher = new JUnit6TestSearcher();
assertTrue(searcher.isTestClass(nestedType));

final Set<IType> discoveredTypes = searcher.findTestItemsInContainer(
nestedType, new NullProgressMonitor());
assertTrue(discoveredTypes.contains(nestedType));
assertEquals(TestKind.JUnit6, searcher.getTestKind());
assertEquals(TestKindRegistry.JUNIT6_TEST_KIND_ID, searcher.getJdtTestKind());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Require-Bundle: org.eclipse.jdt.core,
org.jacoco.core;bundle-version="[0.8.15,0.8.16)"
Export-Package: com.microsoft.java.test.plugin.launchers;x-friends:="com.microsoft.java.test.plugin.test",
com.microsoft.java.test.plugin.model;x-friends:="com.microsoft.java.test.plugin.test",
com.microsoft.java.test.plugin.searcher;x-friends:="com.microsoft.java.test.plugin.test",
com.microsoft.java.test.plugin.coverage;x-friends:="com.microsoft.java.test.plugin.test",
com.microsoft.java.test.plugin.coverage.model;x-friends:="com.microsoft.java.test.plugin.test"
Bundle-ClassPath: .

This file was deleted.

Loading
Loading