Recent Tests: Do not show ignored tests in suites

This commit is contained in:
Yaroslav Lepenkin
2016-02-03 14:48:57 +03:00
parent cb9b8b3b60
commit e915f393e8
3 changed files with 60 additions and 37 deletions
@@ -25,10 +25,9 @@ import java.util.*;
import static com.intellij.execution.testframework.sm.runner.states.TestStateInfo.Magnitude.*;
import static com.intellij.testIntegration.TestInfo.select;
import static com.intellij.testIntegration.TestInfo.selectNot;
public class RecentTestsData {
private static Comparator<TestInfo> TEST_BY_PATH_COMPARATOR = new Comparator<TestInfo>() {
private static Comparator<TestInfo> BY_PATH_COMPARATOR = new Comparator<TestInfo>() {
@Override
public int compare(TestInfo o1, TestInfo o2) {
String path1 = VirtualFileManager.extractPath(o1.getUrl());
@@ -97,27 +96,39 @@ public class RecentTestsData {
public List<String> calculateTestList() {
distributeUnmatchedTests();
List<SuiteInfo> suites = ContainerUtil.newArrayList(mySuites.values());
Collections.sort(suites, TEST_BY_PATH_COMPARATOR);
Collections.sort(myTestsWithoutSuites, TEST_BY_PATH_COMPARATOR);
Collections.sort(suites, SUITE_BY_RECENT_COMPARATOR);
Collections.sort(myTestsWithoutSuites, TEST_BY_RECENT_COMPARATOR);
List<String> result = ContainerUtil.newArrayList();
fillWithSuites(result, select(suites, ERROR_INDEX));
fillWithTests(result, select(myTestsWithoutSuites, ERROR_INDEX));
fillWithSuites(result, selectNot(suites, ERROR_INDEX, COMPLETE_INDEX, PASSED_INDEX));
fillWithTests(result, selectNot(myTestsWithoutSuites, COMPLETE_INDEX, PASSED_INDEX));
fillWithSuites(result, select(suites, COMPLETE_INDEX, PASSED_INDEX));
fillWithTests(result, select(myTestsWithoutSuites, COMPLETE_INDEX, PASSED_INDEX));
fillWithTests(result, ERROR_INDEX, FAILED_INDEX);
fillWithTests(result, COMPLETE_INDEX, PASSED_INDEX, IGNORED_INDEX);
return result;
}
private void fillWithTests(List<String> result, TestStateInfo.Magnitude... magnitudes) {
List<SuiteInfo> suites = ContainerUtil.newArrayList(mySuites.values());
List<SuiteInfo> failedSuites = select(suites, magnitudes);
List<TestInfo> failedTests = select(myTestsWithoutSuites, magnitudes);
sortByPath(failedSuites);
sortByPath(failedTests);
sortSuitesByRecent(failedSuites);
sortTestsByRecent(failedTests);
fillWithSuites(result, failedSuites);
fillWithTests(result, failedTests);
}
private static void sortSuitesByRecent(List<SuiteInfo> suites) {
Collections.sort(suites, SUITE_BY_RECENT_COMPARATOR);
}
private static void sortTestsByRecent(List<TestInfo> tests) {
Collections.sort(tests, TEST_BY_RECENT_COMPARATOR);
}
private static void sortByPath(List<? extends TestInfo> list) {
Collections.sort(list, BY_PATH_COMPARATOR);
}
private static void fillWithTests(List<String> result, List<TestInfo> tests) {
for (TestInfo info : tests) {
@@ -138,7 +149,7 @@ public class RecentTestsData {
Set<TestInfo> allTests = suite.getTests();
List<TestInfo> sameMagnitudeTests = suite.getTests(suiteMagnitude);
if (sameMagnitudeTests.size() == allTests.size()) {
if (sameMagnitudeTests.size() == allTests.size() || suite.getMagnitude() == IGNORED_INDEX) {
result.add(suite.getUrl());
}
else {
@@ -27,7 +27,6 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class SelectTestStep extends BaseListPopupStep<String> {
private final Map<String, TestStateStorage.Record> myRecords;
@@ -84,16 +83,4 @@ public class SelectTestStep extends BaseListPopupStep<String> {
myRunner.run(location);
return null;
}
private static class TestGroup {
public Set<String> failedTests;
public Set<String> passedTests;
public Set<String> otherTests;
public TestGroup(Set<String> failedTests, Set<String> passedTests, Set<String> otherTests) {
this.failedTests = failedTests;
this.passedTests = passedTests;
this.otherTests = otherTests;
}
}
}