From 1e00a12c683a2a956f59c94b9d8257ce7e4ae9d9 Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 13 Jul 2012 17:48:27 +0200 Subject: [PATCH] hide ignored tests (IDEA-61369) --- .../execution/testframework/sm/runner/SMTestProxy.java | 5 +++++ .../execution/testframework/AbstractTestProxy.java | 2 ++ .../src/com/intellij/execution/testframework/Filter.java | 6 ++++++ .../execution/testframework/TestConsoleProperties.java | 1 + .../intellij/execution/testframework/ToolbarPanel.java | 1 + .../testframework/actions/TestFrameworkActions.java | 9 +++++++++ .../src/com/intellij/execution/junit2/TestProxy.java | 5 +++++ .../src/com/theoryinpractice/testng/model/TestProxy.java | 5 +++++ 8 files changed, 34 insertions(+) diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java index 0d610e8d4970..02cd796d711d 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java @@ -152,6 +152,11 @@ public class SMTestProxy extends AbstractTestProxy { return myState.wasTerminated(); } + @Override + public boolean isIgnored() { + return myState.getMagnitude() == TestStateInfo.Magnitude.SKIPPED_INDEX; + } + public boolean isPassed() { return myState.getMagnitude() == TestStateInfo.Magnitude.SKIPPED_INDEX || myState.getMagnitude() == TestStateInfo.Magnitude.COMPLETE_INDEX || diff --git a/platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java b/platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java index 61a213cc6b95..f37184d3e31b 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java @@ -47,6 +47,8 @@ public abstract class AbstractTestProxy extends CompositePrintable { public abstract boolean isInterrupted(); + public abstract boolean isIgnored(); + public abstract boolean isPassed(); public abstract String getName(); diff --git a/platform/testRunner/src/com/intellij/execution/testframework/Filter.java b/platform/testRunner/src/com/intellij/execution/testframework/Filter.java index 25c580b8b493..7d43fcd2a7e1 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/Filter.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/Filter.java @@ -72,6 +72,12 @@ public abstract class Filter { } }; + public static final Filter IGNORED = new Filter() { + public boolean shouldAccept(final AbstractTestProxy test) { + return test.isIgnored(); + } + }; + public static final Filter NOT_PASSED = new Filter() { public boolean shouldAccept(final AbstractTestProxy test) { return !test.isPassed(); diff --git a/platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java b/platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java index fa670d6c4308..96952bb3500d 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java @@ -44,6 +44,7 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp public static final BooleanProperty SORT_ALPHABETICALLY = new BooleanProperty("sortTestsAlphabetically", false); public static final BooleanProperty SELECT_FIRST_DEFECT = new BooleanProperty("selectFirtsDefect", false); public static final BooleanProperty TRACK_RUNNING_TEST = new BooleanProperty("trackRunningTest", true); + public static final BooleanProperty HIDE_IGNORED_TEST = new BooleanProperty("hideIgnoredTests", false); public static final BooleanProperty HIDE_PASSED_TESTS = new BooleanProperty("hidePassedTests", true); public static final BooleanProperty SCROLL_TO_SOURCE = new BooleanProperty("scrollToSource", false); public static final BooleanProperty OPEN_FAILURE_LINE = new BooleanProperty("openFailureLine", false); diff --git a/platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java b/platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java index 219a20b59bc9..06f530090813 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java @@ -67,6 +67,7 @@ public class ToolbarPanel extends JPanel implements OccurenceNavigator, Disposab ExecutionBundle.message("junit.runing.info.track.test.action.description"), AllIcons.RunConfigurations.TrackTests, properties, TestConsoleProperties.TRACK_RUNNING_TEST)).setAsSecondary(true); + actionGroup.addAction(new ToggleBooleanProperty("Hide Ignored", null, null, properties, TestConsoleProperties.HIDE_IGNORED_TEST)).setAsSecondary(true); actionGroup.addAction(new ToggleBooleanProperty(ExecutionBundle.message("junit.runing.info.sort.alphabetically.action.name"), ExecutionBundle.message("junit.runing.info.sort.alphabetically.action.description"), diff --git a/platform/testRunner/src/com/intellij/execution/testframework/actions/TestFrameworkActions.java b/platform/testRunner/src/com/intellij/execution/testframework/actions/TestFrameworkActions.java index 45908640edc4..5d2f9d2cb70c 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/actions/TestFrameworkActions.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/actions/TestFrameworkActions.java @@ -38,6 +38,15 @@ public class TestFrameworkActions { } }; addPropertyListener(TestConsoleProperties.HIDE_PASSED_TESTS, hidePropertyListener, model, true); + + final TestConsoleProperties ignoreProperties = model.getProperties(); + final TestFrameworkPropertyListener ignorePropertyListener = new TestFrameworkPropertyListener() { + public void onChanged(final Boolean value) { + final boolean shouldFilter = TestConsoleProperties.HIDE_IGNORED_TEST.value(ignoreProperties); + model.setFilter(shouldFilter ? Filter.IGNORED.not() : Filter.NO_FILTER); + } + }; + addPropertyListener(TestConsoleProperties.HIDE_IGNORED_TEST, ignorePropertyListener, model, true); } public static void addPropertyListener(final AbstractProperty property, diff --git a/plugins/junit/src/com/intellij/execution/junit2/TestProxy.java b/plugins/junit/src/com/intellij/execution/junit2/TestProxy.java index 0f19fb6c1247..a536a7f4d119 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/TestProxy.java +++ b/plugins/junit/src/com/intellij/execution/junit2/TestProxy.java @@ -141,6 +141,11 @@ public class TestProxy extends AbstractTestProxy { return getMagnitude() == PoolOfTestStates.TERMINATED_INDEX; } + @Override + public boolean isIgnored() { + return getMagnitude() == PoolOfTestStates.IGNORED_INDEX; + } + public boolean isPassed() { return getMagnitude() <= PoolOfTestStates.PASSED_INDEX; } diff --git a/plugins/testng/src/com/theoryinpractice/testng/model/TestProxy.java b/plugins/testng/src/com/theoryinpractice/testng/model/TestProxy.java index 3a10c64b75e5..1b6ed0bcad14 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/model/TestProxy.java +++ b/plugins/testng/src/com/theoryinpractice/testng/model/TestProxy.java @@ -230,6 +230,11 @@ public class TestProxy extends AbstractTestProxy { return !isInProgress() && inProgress; } + @Override + public boolean isIgnored() { + return resultMessage != null && MessageHelper.SKIPPED_TEST == resultMessage.getResult(); + } + public boolean isTearDownFailure() { for (TestProxy result : results) { if (result.isTearDownFailure()) return true;