Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Chandra2018-06-15 12:28:27 +0000
committerVikas Chandra2018-06-20 05:08:48 +0000
commita2895f06b99ca7ae9b832a1e1a253412e5a58dc4 (patch)
treeab4f2b8e756352de44d74400ee4aac28ac37bc5a
parentaf3d1c4d6139d21a41413efeb35a6f421b559683 (diff)
downloadeclipse.jdt.ui-a2895f06b99ca7ae9b832a1e1a253412e5a58dc4.tar.gz
eclipse.jdt.ui-a2895f06b99ca7ae9b832a1e1a253412e5a58dc4.tar.xz
eclipse.jdt.ui-a2895f06b99ca7ae9b832a1e1a253412e5a58dc4.zip
Bug 535530 - Remove program argument addition workaround as a way of
running JUnit plugin test case for some scenarios Change-Id: Iedc44c5524b5ea1958faf3c4299209867c38233b Signed-off-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
-rw-r--r--org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java8
-rw-r--r--org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/TestKindRegistry.java2
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java6
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchShortcut.java6
4 files changed, 18 insertions, 4 deletions
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java
index 44a7ca4735..48533e7a18 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM 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
@@ -42,6 +42,12 @@ public class JUnitLaunchConfigurationConstants {
public static final String ATTR_DONT_ADD_MISSING_JUNIT5_DEPENDENCY= JUnitCorePlugin.PLUGIN_ID + ".DONT_ADD_MISSING_JUNIT5_DEPENDENCY"; //$NON-NLS-1$
/**
+ * If the element is a test class annotated with <code>@RunWith(JUnitPlatform.class)</code>,
+ * this attribute is set to true.
+ */
+ public static final String ATTR_RUN_WITH_JUNIT_PLATFORM_ANNOTATION= JUnitCorePlugin.PLUGIN_ID + ".IS_RUN_WITH_JUNIT_PLATFORM"; //$NON-NLS-1$
+
+ /**
* The test method name (followed by a comma-separated list of fully qualified parameter type
* names in parentheses, if exists), or "" iff running the whole test type.
*/
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/TestKindRegistry.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/TestKindRegistry.java
index b8a734227d..7bd1da3e97 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/TestKindRegistry.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/TestKindRegistry.java
@@ -135,7 +135,7 @@ public class TestKindRegistry {
* @return <code>true</code> if the element is a test class annotated with
* <code>@RunWith(JUnitPlatform.class)</code>
*/
- private static boolean isRunWithJUnitPlatform(IJavaElement element) {
+ public static boolean isRunWithJUnitPlatform(IJavaElement element) {
if (element instanceof ICompilationUnit) {
element= ((ICompilationUnit) element).findPrimaryType();
}
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java
index c8b60c6bdb..ec4b23a02e 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM 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
@@ -1146,6 +1146,10 @@ public class JUnitLaunchConfigurationTab extends AbstractLaunchConfigurationTab
if (testKindId != null)
config.setAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_RUNNER_KIND, testKindId);
initializeName(config, name);
+ boolean isRunWithJUnitPlatform= TestKindRegistry.isRunWithJUnitPlatform(javaElement);
+ if (isRunWithJUnitPlatform) {
+ config.setAttribute(JUnitLaunchConfigurationConstants.ATTR_RUN_WITH_JUNIT_PLATFORM_ANNOTATION, true);
+ }
}
@Override
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchShortcut.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchShortcut.java
index d9202ce3a8..9d0e11227f 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchShortcut.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchShortcut.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM 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
@@ -375,6 +375,10 @@ public class JUnitLaunchShortcut implements ILaunchShortcut2 {
if (testName != null) {
wc.setAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_NAME, testName);
}
+ boolean isRunWithJUnitPlatform= TestKindRegistry.isRunWithJUnitPlatform(element);
+ if (isRunWithJUnitPlatform) {
+ wc.setAttribute(JUnitLaunchConfigurationConstants.ATTR_RUN_WITH_JUNIT_PLATFORM_ANNOTATION, true);
+ }
return wc;
}

Back to the top