mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
junit 5: exclude vintage engine when no junit 4 present in the classpath (IDEA-158667)
This commit is contained in:
@@ -168,10 +168,20 @@ public abstract class TestObject extends JavaTestFrameworkRunnableState<JUnitCon
|
||||
}
|
||||
|
||||
final Project project = getConfiguration().getProject();
|
||||
if (JUnitUtil.isJUnit5(GlobalSearchScope.allScope(project), project)) {
|
||||
final SourceScope sourceScope = getSourceScope();
|
||||
final GlobalSearchScope scope = sourceScope != null ? sourceScope.getLibrariesScope() : GlobalSearchScope.allScope(project);
|
||||
if (JUnitUtil.isJUnit5(scope, project)) {
|
||||
javaParameters.getProgramParametersList().add(JUnitStarter.JUNIT5_PARAMETER);
|
||||
javaParameters.getClassPath().add(PathUtil.getJarPathForClass(JUnit5IdeaTestRunner.class));
|
||||
|
||||
boolean excludeVintage = false;
|
||||
try {
|
||||
JUnitUtil.getTestCaseClass(sourceScope);
|
||||
}
|
||||
catch (JUnitUtil.NoJUnitException e) {
|
||||
excludeVintage = true;
|
||||
}
|
||||
|
||||
final PathsList classPath = javaParameters.getClassPath();
|
||||
final List<String> paths = classPath.getPathList();
|
||||
final String pathForClass = PathUtil.getJarPathForClass(TestExecutionListener.class);
|
||||
@@ -180,6 +190,8 @@ public abstract class TestObject extends JavaTestFrameworkRunnableState<JUnitCon
|
||||
if (libJars != null) {
|
||||
for (File jarFile : libJars) {
|
||||
final String filePath = jarFile.getAbsolutePath();
|
||||
if (excludeVintage && filePath.contains("vintage")) continue;
|
||||
|
||||
if (!paths.contains(filePath)) {
|
||||
classPath.add(filePath);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class JUnitStarter {
|
||||
|
||||
String agentName = processParameters(argList, listeners, name);
|
||||
|
||||
if (!canWorkWithJUnitVersion(System.err, agentName)) {
|
||||
if (!JUNIT5_RUNNER_NAME.equals(agentName) && !canWorkWithJUnitVersion(System.err, agentName)) {
|
||||
System.exit(-3);
|
||||
}
|
||||
if (!checkVersion(args, System.err)) {
|
||||
@@ -221,7 +221,7 @@ public class JUnitStarter {
|
||||
Class.forName("junit.framework.ComparisonFailure");
|
||||
getAgentClass(agentName);
|
||||
//noinspection UnnecessaryFullyQualifiedName
|
||||
new junit.textui.TestRunner().setPrinter(new com.intellij.junit3.JUnit3IdeaTestRunner.MockResultPrinter());
|
||||
new junit.textui.TestRunner().setPrinter(null); //
|
||||
}
|
||||
|
||||
private static int prepareStreamsAndStart(String[] args,
|
||||
|
||||
Reference in New Issue
Block a user