tests view: hide ignored/hide passed filters combinations (IDEA-121329)

This commit is contained in:
Anna Kozlova
2015-06-24 17:40:48 +03:00
parent ebff840429
commit b3a49ff090
7 changed files with 139 additions and 8 deletions
@@ -182,11 +182,7 @@ public class SMTestProxy extends AbstractTestProxy {
}
@Override
public boolean isInterrupted() {
return myState.wasTerminated();
}
boolean hasPassedTests() {
public boolean hasPassedTests() {
if (myHasPassedTestsCached) {
return myHasPassedTests;
}
@@ -197,6 +193,11 @@ public class SMTestProxy extends AbstractTestProxy {
myHasPassedTestsCached = true;
}
return hasPassedTests;
}
@Override
public boolean isInterrupted() {
return myState.wasTerminated();
}
private boolean calcPassedTests() {
@@ -213,8 +214,7 @@ public class SMTestProxy extends AbstractTestProxy {
@Override
public boolean isIgnored() {
return !hasPassedTests() &&
myState.getMagnitude() == TestStateInfo.Magnitude.IGNORED_INDEX;
return myState.getMagnitude() == TestStateInfo.Magnitude.IGNORED_INDEX;
}
public boolean isPassed() {
@@ -0,0 +1,105 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.execution.testframework.sm.runner.ui;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.execution.testframework.sm.runner.BaseSMTRunnerTestCase;
import com.intellij.execution.testframework.sm.runner.SMTRunnerTreeStructure;
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
import com.intellij.openapi.util.Disposer;
import javax.swing.*;
public class SMTRunnerFiltersTest extends BaseSMTRunnerTestCase {
private MockTestResultsViewer myResultsViewer;
private TestConsoleProperties myProperties;
private SMTestRunnerResultsForm myResultsForm;
@Override
protected void setUp() throws Exception {
super.setUp();
myProperties = createConsoleProperties();
myResultsViewer = new MockTestResultsViewer(myProperties, mySuite);
TestConsoleProperties.HIDE_PASSED_TESTS.set(myProperties, false);
TestConsoleProperties.HIDE_IGNORED_TEST.set(myProperties, false);
myResultsForm = new SMTestRunnerResultsForm(new JLabel(), myProperties);
Disposer.register(myResultsForm, myProperties);
myResultsForm.initUI();
//setup suites tree
mySuite.setStarted();
final SMTestProxy testsSuite = createSuiteProxy("my suite", mySuite);
testsSuite.setStarted();
// passed test
final SMTestProxy testPassed1 = createTestProxy("testPassed1", testsSuite);
testPassed1.setStarted();
testPassed1.setFinished();
//ignored test
final SMTestProxy testIgnored1 = createTestProxy("testIgnored1", testsSuite);
testIgnored1.setStarted();
testIgnored1.setTestIgnored("", "");
testsSuite.setFinished();
mySuite.setFinished();
}
@Override
protected void tearDown() throws Exception {
Disposer.dispose(myResultsViewer);
Disposer.dispose(myResultsForm);
super.tearDown();
}
public void testShowPassedShowIgnored() {
final SMTRunnerTreeStructure treeStructure = myResultsForm.getTreeBuilder().getSMRunnerTreeStructure();
final Object[] suites = treeStructure.getChildElements(mySuite);
assertTrue(suites.length == 1);
final Object[] tests = treeStructure.getChildElements(suites[0]);
assertTrue(tests.length == 2);
}
public void testShowPassedHideIgnored() {
TestConsoleProperties.HIDE_IGNORED_TEST.set(myProperties, true);
final SMTRunnerTreeStructure treeStructure = myResultsForm.getTreeBuilder().getSMRunnerTreeStructure();
final Object[] suites = treeStructure.getChildElements(mySuite);
assertTrue(suites.length == 1);
final Object[] tests = treeStructure.getChildElements(suites[0]);
assertTrue(tests.length == 1);
assertTrue(tests[0] instanceof SMTestProxy && "testPassed1".equals(((SMTestProxy)tests[0]).getName()));
}
public void testShowIgnoredHidePassed() {
TestConsoleProperties.HIDE_PASSED_TESTS.set(myProperties, true);
final SMTRunnerTreeStructure treeStructure = myResultsForm.getTreeBuilder().getSMRunnerTreeStructure();
final Object[] suites = treeStructure.getChildElements(mySuite);
assertTrue(suites.length == 1);
final Object[] tests = treeStructure.getChildElements(suites[0]);
assertTrue(tests.length == 1);
assertTrue(tests[0] instanceof SMTestProxy && "testIgnored1".equals(((SMTestProxy)tests[0]).getName()));
}
public void testHidePassedHideIgnored() {
TestConsoleProperties.HIDE_PASSED_TESTS.set(myProperties, true);
TestConsoleProperties.HIDE_IGNORED_TEST.set(myProperties, true);
final SMTRunnerTreeStructure treeStructure = myResultsForm.getTreeBuilder().getSMRunnerTreeStructure();
final Object[] suites = treeStructure.getChildElements(mySuite);
assertTrue(suites.length == 0);
}
}
@@ -48,6 +48,8 @@ public abstract class AbstractTestProxy extends CompositePrintable {
public abstract boolean isInterrupted();
public abstract boolean hasPassedTests();
public abstract boolean isIgnored();
public abstract boolean isPassed();
@@ -95,6 +95,13 @@ public abstract class Filter<T extends AbstractTestProxy> {
}
};
public static final Filter HAS_PASSED = new Filter() {
@Override
public boolean shouldAccept(final AbstractTestProxy test) {
return test.hasPassedTests();
}
};
public static final Filter FAILED_OR_INTERRUPTED = new Filter() {
@Override
public boolean shouldAccept(final AbstractTestProxy test) {
@@ -51,7 +51,14 @@ public class TestFrameworkActions {
final Filter hidePassedFilter = shouldFilterPassed ? Filter.NOT_PASSED.or(Filter.DEFECT) : Filter.NO_FILTER;
final boolean shouldFilterIgnored = TestConsoleProperties.HIDE_IGNORED_TEST.value(properties);
final Filter hideIgnoredFilter = shouldFilterIgnored ? Filter.IGNORED.not() : Filter.NO_FILTER;
final Filter hideIgnoredFilter;
if (shouldFilterIgnored) {
final Filter ignoredFilter = Filter.IGNORED.not();
hideIgnoredFilter = !shouldFilterPassed ? ignoredFilter.or(Filter.HAS_PASSED) : ignoredFilter;
}
else {
hideIgnoredFilter = Filter.NO_FILTER;
}
return hidePassedFilter.and(hideIgnoredFilter);
}
@@ -172,6 +172,11 @@ public class TestProxy extends AbstractTestProxy {
return getMagnitude() == PoolOfTestStates.TERMINATED_INDEX;
}
@Override
public boolean hasPassedTests() {
return isPassed();
}
@Override
public boolean isIgnored() {
return myState instanceof IgnoredState;
@@ -238,6 +238,11 @@ public class TestProxy extends AbstractTestProxy {
return !isInProgress() && inProgress;
}
@Override
public boolean hasPassedTests() {
return isPassed();
}
@Override
public boolean isIgnored() {
return resultMessage != null && MessageHelper.SKIPPED_TEST == resultMessage.getResult();