Return tree structure in test view result for running single test
This commit is contained in:
@@ -16,13 +16,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet;
|
package org.jetbrains.jet;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestResult;
|
import junit.framework.TestResult;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import kotlin.Function1;
|
|
||||||
import kotlin.KotlinPackage;
|
|
||||||
import org.junit.internal.MethodSorter;
|
import org.junit.internal.MethodSorter;
|
||||||
import org.junit.internal.runners.JUnit38ClassRunner;
|
import org.junit.internal.runners.JUnit38ClassRunner;
|
||||||
import org.junit.runner.Description;
|
import org.junit.runner.Description;
|
||||||
@@ -121,22 +118,31 @@ public class JUnit3RunnerWithInners extends Runner implements Filterable, Sortab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
List<Class> classes = Lists.newArrayList();
|
assert unprocessedInnerClasses.size() == innerClasses.size() :
|
||||||
classes.add(klass);
|
String.format("Some inner classes left unprocessed during creating runner for %s: %s",
|
||||||
classes.addAll(unprocessedInnerClasses);
|
klass.getCanonicalName(), unprocessedInnerClasses);
|
||||||
|
|
||||||
List<Class> filtered = KotlinPackage.filter(classes, new Function1<Class, Boolean>() {
|
return createTreeTestSuite(klass);
|
||||||
@Override
|
|
||||||
public Boolean invoke(Class aClass) {
|
|
||||||
boolean hasInnerClasses = aClass.getDeclaredClasses().length > 0;
|
|
||||||
return !hasInnerClasses || hasTestMethods(aClass);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return new TestSuite(filtered.toArray(new Class[filtered.size()]));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Test createTreeTestSuite(Class root) {
|
||||||
|
Set<Class> classes = new LinkedHashSet<Class>(collectDeclaredClasses(root, true));
|
||||||
|
Map<Class, TestSuite> classSuites = new HashMap<Class, TestSuite>();
|
||||||
|
|
||||||
|
for (Class aClass : classes) {
|
||||||
|
classSuites.put(aClass, hasTestMethods(aClass) ? new TestSuite(aClass) : new TestSuite(aClass.getCanonicalName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Class aClass : classes) {
|
||||||
|
if (aClass.getEnclosingClass() != null && classes.contains(aClass.getEnclosingClass())) {
|
||||||
|
classSuites.get(aClass.getEnclosingClass()).addTest(classSuites.get(aClass));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return classSuites.get(root);
|
||||||
|
}
|
||||||
|
|
||||||
private static Set<Class> unprocessedClasses(Collection<Class> classes) {
|
private static Set<Class> unprocessedClasses(Collection<Class> classes) {
|
||||||
Set<Class> result = new LinkedHashSet<Class>();
|
Set<Class> result = new LinkedHashSet<Class>();
|
||||||
for (Class aClass : classes) {
|
for (Class aClass : classes) {
|
||||||
|
|||||||
Reference in New Issue
Block a user