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
35 changes: 22 additions & 13 deletions java-extension/com.microsoft.java.test.plugin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,28 @@ Require-Bundle: org.eclipse.jdt.core,
org.eclipse.jdt.junit.runtime,
org.eclipse.jdt.junit4.runtime,
org.eclipse.jdt.junit5.runtime,
junit-jupiter-api;bundle-version="5.4.0",
junit-jupiter-engine;bundle-version="5.4.0",
junit-jupiter-migrationsupport;bundle-version="5.4.0",
junit-jupiter-params;bundle-version="5.4.0",
junit-vintage-engine;bundle-version="5.4.0",
org.opentest4j;bundle-version="1.1.1",
junit-platform-commons;bundle-version="1.4.0",
junit-platform-engine;bundle-version="1.4.0",
junit-platform-launcher;bundle-version="1.4.0",
junit-platform-runner;bundle-version="1.4.0",
junit-platform-suite-api;bundle-version="1.4.0",
junit-platform-suite-commons;bundle-version="1.8.1",
junit-platform-suite-engine;bundle-version="1.8.1",
junit-jupiter-api;bundle-version="5.14.0",
junit-jupiter-engine;bundle-version="5.14.0",
junit-jupiter-migrationsupport;bundle-version="5.14.0",
junit-jupiter-params;bundle-version="5.14.0",
junit-vintage-engine;bundle-version="5.14.0",
junit-platform-commons;bundle-version="1.14.1",
junit-platform-engine;bundle-version="1.14.1",
junit-platform-launcher;bundle-version="1.14.1",
junit-platform-runner;bundle-version="1.14.1",
junit-platform-suite-api;bundle-version="1.14.1",
junit-platform-suite-commons;bundle-version="1.14.1",
junit-platform-suite-engine;bundle-version="1.14.1",
org.eclipse.jdt.junit6.runtime,
junit-jupiter-api;bundle-version="6.0.1",
junit-jupiter-engine;bundle-version="6.0.1",
junit-jupiter-params;bundle-version="6.0.1",
org.opentest4j;bundle-version="1.3.0",
junit-platform-commons;bundle-version="6.0.1",
junit-platform-engine;bundle-version="6.0.1",
junit-platform-launcher;bundle-version="6.0.1",
junit-platform-suite-api;bundle-version="6.0.1",
junit-platform-suite-engine;bundle-version="6.0.1",
org.apiguardian.api;bundle-version="1.0.0",
org.apache.commons.lang3;bundle-version="3.1.0",
com.google.gson;bundle-version="2.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public Map<String, String> toValueMap() {
final Map<String, String> valueMap = new HashMap<>();
valueMap.put("testKind", testKind);
valueMap.put("mainType", mainType);
valueMap.put("projectName", project.getName());
return valueMap;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ private void addTestItemArgs(List<String> arguments) throws CoreException {
arguments.add("-test");
final IMethod method = (IMethod) JavaCore.create(this.args.testNames[0]);
String testName = method.getElementName();
if (this.args.testKind == TestKind.JUnit5 && method.getParameters().length > 0) {
if ((this.args.testKind == TestKind.JUnit5 || this.args.testKind == TestKind.JUnit6) &&
method.getParameters().length > 0) {
final ICompilationUnit unit = method.getCompilationUnit();
if (unit == null) {
throw new CoreException(new Status(IStatus.ERROR, JUnitPlugin.PLUGIN_ID, IStatus.ERROR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class JUnitLaunchConfigurationTemplate {
"<booleanAttribute key=\"org.eclipse.jdt.junit.KEEPRUNNING_ATTR\" value=\"false\"/>\n" +
"<stringAttribute key=\"org.eclipse.jdt.junit.TEST_KIND\" value=\"${testKind}\"/>\n" +
"<stringAttribute key=\"org.eclipse.jdt.launching.MAIN_TYPE\" value=\"${mainType}\"/>\n" +
"<stringAttribute key=\"org.eclipse.jdt.launching.PROJECT_ATTR\" value=\"${projectName}\"/>\n" +
"<stringAttribute key=\"org.eclipse.jdt.launching.VM_ARGUMENTS\" value=\"-ea\"/>\n" +
"</launchConfiguration>\n";
//@formatter:on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
public class JUnitLaunchUtils {

private static final String TESTNG_LOADER = "com.microsoft.java.test.loader.testng";
private static final String JUNIT6_LOADER = "org.eclipse.jdt.junit.loader.junit6";
private static final String JUNIT5_LOADER = "org.eclipse.jdt.junit.loader.junit5";
private static final String JUNIT4_LOADER = "org.eclipse.jdt.junit.loader.junit4";

Expand Down Expand Up @@ -205,6 +206,8 @@ private static String getEclipseTestKind(TestKind testKind) {
return JUNIT4_LOADER;
case JUnit5:
return JUNIT5_LOADER;
case JUnit6:
return JUNIT6_LOADER;
case TestNG:
return TESTNG_LOADER;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@ public enum TestKind {
@SerializedName("2")
TestNG(2),

@SerializedName("3")
JUnit6(3),

@SerializedName("100")
None(100);

private int value;

public static TestKind fromString(String s) {
switch(s) {
switch (s) {
case "Unknown":
return None;
case "JUnit 4":
return JUnit;
case "JUnit 5":
return JUnit5;
case "JUnit 6":
return JUnit6;
case "TestNG":
return TestNG;
default:
Expand All @@ -53,6 +58,8 @@ public String toString() {
return "JUnit 4";
case JUnit5:
return "JUnit 5";
case JUnit6:
return "JUnit 6";
case TestNG:
return "TestNG";
default:
Expand All @@ -64,7 +71,7 @@ public int getValue() {
return this.value;
}

private TestKind(int value){
private TestKind(int value) {
this.value = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.junit.util.CoreTestSearchEngine;

import java.util.HashMap;
import java.util.LinkedList;
Expand Down Expand Up @@ -44,7 +45,10 @@ public static List<TestKind> getTestKindsFromCache(IJavaProject javaProject) {
private static List<TestKind> getTestKinds(IJavaProject javaProject) {
final List<TestKind> result = new LinkedList<>();
try {
if (javaProject.findType(JUNIT5_TEST) != null) {
// Check for JUnit 6 first using Eclipse JDT's built-in detection
if (CoreTestSearchEngine.hasJUnit6TestAnnotation(javaProject)) {
result.add(TestKind.JUnit6);
} else if (CoreTestSearchEngine.hasJUnit5TestAnnotation(javaProject)) {
result.add(TestKind.JUnit5);
}

Expand Down
Loading