mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
rerun failed tests with @Parameterized runner: one test method can cause multiple test failures
This commit is contained in:
@@ -37,7 +37,7 @@ import com.intellij.rt.execution.junit.JUnitStarter;
|
||||
import com.intellij.util.Function;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
public class TestMethods extends TestMethod {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit.TestMethods");
|
||||
@@ -71,20 +71,18 @@ public class TestMethods extends TestMethod {
|
||||
}
|
||||
});
|
||||
if (exception[0] != null) throw exception[0];
|
||||
final LinkedHashMap<PsiMethod, TestInfo> methods = new LinkedHashMap<PsiMethod, TestInfo>();
|
||||
final LinkedHashSet<TestInfo> methods = new LinkedHashSet<TestInfo>();
|
||||
for (AbstractTestProxy failedTest : myFailedTests) {
|
||||
Location location = failedTest.getLocation(project);
|
||||
if (!(location instanceof MethodLocation)) continue;
|
||||
PsiElement psiElement = location.getPsiElement();
|
||||
LOG.assertTrue(psiElement instanceof PsiMethod);
|
||||
PsiMethod method = (PsiMethod)psiElement;
|
||||
methods.put(method, ((TestProxy)failedTest).getInfo());
|
||||
methods.add(((TestProxy)failedTest).getInfo());
|
||||
}
|
||||
addClassesListToJavaParameters(methods.keySet(), new Function<PsiElement, String>() {
|
||||
public String fun(PsiElement element) {
|
||||
if (element instanceof PsiMethod) {
|
||||
final PsiMethod method = (PsiMethod)element;
|
||||
final TestInfo testInfo = methods.get(method);
|
||||
addClassesListToJavaParameters(methods, new Function<TestInfo, String>() {
|
||||
public String fun(TestInfo testInfo) {
|
||||
if (testInfo != null) {
|
||||
final MethodLocation location = (MethodLocation)testInfo.getLocation(project);
|
||||
LOG.assertTrue(location != null);
|
||||
return JavaExecutionUtil.getRuntimeQualifiedName(location.getContainingClass()) + "," + testInfo.getName();
|
||||
|
||||
@@ -285,7 +285,7 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
}
|
||||
|
||||
|
||||
protected void addClassesListToJavaParameters(Collection<? extends PsiElement> elements, Function<PsiElement, String> nameFunction, String packageName,
|
||||
protected <T> void addClassesListToJavaParameters(Collection<? extends T> elements, Function<T, String> nameFunction, String packageName,
|
||||
boolean createTempFile,
|
||||
boolean junit4) {
|
||||
try {
|
||||
@@ -300,7 +300,7 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
writer.println(junit4 ? JUnitStarter.JUNIT4_PARAMETER : "-junit3");
|
||||
writer.println(packageName);
|
||||
final List<String> testNames = new ArrayList<String>();
|
||||
for (final PsiElement element : elements) {
|
||||
for (final T element : elements) {
|
||||
final String name = nameFunction.fun(element);
|
||||
if (name == null) {
|
||||
LOG.error("invalid element " + element);
|
||||
|
||||
Reference in New Issue
Block a user