diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java index 0b0bea6cac7c..e299d40eaf60 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java @@ -16,7 +16,6 @@ package com.intellij.execution.testframework.sm.runner; import com.intellij.execution.process.ProcessOutputTypes; -import com.intellij.execution.testframework.AbstractTestProxy; import com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil; import com.intellij.execution.testframework.sm.runner.events.*; import com.intellij.openapi.application.Application; @@ -38,7 +37,6 @@ import java.util.*; public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcessor { private final Map myRunningTestsFullNameToProxy = new HashMap(); - private final Set myFailedTestsSet = new HashSet(); private final TestSuiteStack mySuitesStack; private final Set myCurrentChildren = new LinkedHashSet(); private boolean myGetChildren = true; @@ -393,15 +391,13 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso cannotFindFullTestNameMsg(fullTestName)); if (inDebugMode) { return; - } else { - // try to fix the problem: - if (!myFailedTestsSet.contains(testProxy)) { - // if hasn't been already reported - // 1. report - onTestStarted(new TestStartedEvent(testName, null)); - // 2. add failure - testProxy = getProxyByFullTestName(fullTestName); - } + } + else { + // if hasn't been already reported + // 1. report + onTestStarted(new TestStartedEvent(testName, null)); + // 2. add failure + testProxy = getProxyByFullTestName(fullTestName); } } @@ -410,21 +406,14 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso } if (comparisionFailureActualText != null && comparisionFailureExpectedText != null) { - if (myFailedTestsSet.contains(testProxy)) { - // duplicate message - logProblem("Duplicate failure for test [" + fullTestName + "]: msg = " + localizedMessage + ", stacktrace = " + stackTrace); - - if (inDebugMode) { - return; - } - } - testProxy.setTestComparisonFailed(localizedMessage, stackTrace, comparisionFailureActualText, comparisionFailureExpectedText, testFailedEvent.getFilePath(), testFailedEvent.getActualFilePath()); - } else if (comparisionFailureActualText == null && comparisionFailureExpectedText == null) { + } + else if (comparisionFailureActualText == null && comparisionFailureExpectedText == null) { testProxy.setTestFailed(localizedMessage, stackTrace, isTestError); - } else { + } + else { logProblem("Comparison failure actual and expected texts should be both null or not null.\n" + "Expected:\n" + comparisionFailureExpectedText + "\n" @@ -432,8 +421,6 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso + comparisionFailureActualText); } - myFailedTestsSet.add(testProxy); - // fire event fireOnTestFailed(testProxy); } @@ -535,10 +522,6 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso return myRunningTestsFullNameToProxy.size(); } - protected Set getFailedTestsSet() { - return Collections.unmodifiableSet(myFailedTestsSet); - } - @Nullable protected SMTestProxy getProxyByFullTestName(final String fullTestName) { return myRunningTestsFullNameToProxy.get(fullTestName); 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 4a9019fcbb85..dfc00091503b 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 @@ -480,8 +480,20 @@ public class SMTestProxy extends AbstractTestProxy { @Nullable final String expectedFilePath, @Nullable final String actualFilePath) { setStacktraceIfNotSet(stackTrace); - myState = new TestComparisionFailedState(localizedMessage, stackTrace, actualText, expectedText, expectedFilePath, actualFilePath); - fireOnNewPrintable(myState); + final TestComparisionFailedState comparisionFailedState = new TestComparisionFailedState(localizedMessage, stackTrace, actualText, expectedText, expectedFilePath, actualFilePath); + if (myState instanceof TestComparisionFailedState) { + final TestComparisonFailedStates states = new TestComparisonFailedStates(localizedMessage, stackTrace); + states.addComparisonFailure((TestComparisionFailedState)myState); + states.addComparisonFailure(comparisionFailedState); + myState = states; + } + else if (myState instanceof TestComparisonFailedStates) { + ((TestComparisonFailedStates)myState).addComparisonFailure(comparisionFailedState); + } + else { + myState = comparisionFailedState; + } + fireOnNewPrintable(comparisionFailedState); } public void setTestIgnored(@Nullable String ignoreComment, @Nullable String stackTrace) { @@ -627,6 +639,10 @@ public class SMTestProxy extends AbstractTestProxy { return ((TestComparisionFailedState)myState).getHyperlink(); } + if (myState instanceof TestComparisonFailedStates) { + return ((TestComparisonFailedStates)myState).getHyperlinks().get(0); + } + if (myChildren != null) { for (SMTestProxy child : myChildren) { if (!child.isDefect()) continue; @@ -639,6 +655,15 @@ public class SMTestProxy extends AbstractTestProxy { return null; } + @Nullable + @Override + public List getDiffViewerProviders() { + if (myState instanceof TestComparisonFailedStates) { + return ((TestComparisonFailedStates)myState).getHyperlinks(); + } + return super.getDiffViewerProviders(); + } + @Override public String toString() { return getPresentableName(); diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisonFailedStates.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisonFailedStates.java new file mode 100644 index 000000000000..e065548d66ce --- /dev/null +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisonFailedStates.java @@ -0,0 +1,58 @@ +/* + * 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.states; + + +import com.intellij.execution.testframework.Printer; +import com.intellij.execution.testframework.stacktrace.DiffHyperlink; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +public class TestComparisonFailedStates extends TestFailedState { + + final List myStates = new ArrayList(); + + public TestComparisonFailedStates(@Nullable String localizedMessage, @Nullable String stackTrace) { + super(localizedMessage, stackTrace); + } + + public void addComparisonFailure(TestComparisionFailedState state) { + myStates.add(state); + } + + @Override + public void printOn(Printer printer) { + + for (TestComparisionFailedState state : myStates) { + state.printOn(printer); + } + } + + @NotNull + public List getHyperlinks() { + return ContainerUtil.map(myStates, new Function() { + @Override + public DiffHyperlink fun(TestComparisionFailedState state) { + return state.getHyperlink(); + } + }); + } +} diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertorTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertorTest.java index 90b8559b7f42..e4231cfbd586 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertorTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertorTest.java @@ -16,11 +16,10 @@ package com.intellij.execution.testframework.sm.runner; import com.intellij.execution.runners.ExecutionEnvironment; -import com.intellij.execution.testframework.AbstractTestProxy; import com.intellij.execution.testframework.TestConsoleProperties; -import com.intellij.execution.testframework.sm.runner.history.ImportedToGeneralTestEventsConverter; import com.intellij.execution.testframework.sm.Marker; import com.intellij.execution.testframework.sm.runner.events.*; +import com.intellij.execution.testframework.sm.runner.history.ImportedToGeneralTestEventsConverter; import com.intellij.execution.testframework.sm.runner.ui.MockPrinter; import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView; import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerTestTreeView; @@ -35,7 +34,6 @@ import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeModel; import java.io.StringReader; import java.util.List; -import java.util.Set; /** * @author Roman Chernyatchik @@ -184,11 +182,6 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase myEventsProcessor.onTestFailure(new TestFailedEvent("some_test", "msg 2", "trace 2", false, null, null)); assertEquals(1, myEventsProcessor.getRunningTestsQuantity()); - final Set failedTests = myEventsProcessor.getFailedTestsSet(); - assertEquals(1, failedTests.size()); - for (final AbstractTestProxy test : failedTests) { - assertEquals("some_test", test.getName()); - } assertEquals("\nmsg 1\ntrace 1\n\nmsg 2\ntrace 2\n", myMockResettablePrinter.getStdErr()); } @@ -223,7 +216,6 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase myEventsProcessor.onTestFinished(new TestFinishedEvent("some_test", 10l)); assertEquals(0, myEventsProcessor.getRunningTestsQuantity()); - assertEquals(0, myEventsProcessor.getFailedTestsSet().size()); assertNotNull(proxy); assertFalse(proxy.isDefect()); diff --git a/platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java b/platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java index 11baa5a5de60..b89227873d88 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java @@ -25,6 +25,7 @@ import com.intellij.psi.search.GlobalSearchScope; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Collections; import java.util.List; /** @@ -142,6 +143,12 @@ public abstract class AbstractTestProxy extends CompositePrintable { return myExceptionMark; } + @Nullable + public List getDiffViewerProviders() { + final DiffHyperlink provider = getDiffViewerProvider(); + return provider == null ? null : Collections.singletonList(provider); + } + @Nullable public DiffHyperlink getDiffViewerProvider() { return null; diff --git a/platform/testRunner/src/com/intellij/execution/testframework/actions/ViewAssertEqualsDiffAction.java b/platform/testRunner/src/com/intellij/execution/testframework/actions/ViewAssertEqualsDiffAction.java index 8fa4a2a1df7f..bb9568c63ba4 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/actions/ViewAssertEqualsDiffAction.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/actions/ViewAssertEqualsDiffAction.java @@ -75,9 +75,9 @@ public class ViewAssertEqualsDiffAction extends AnAction implements TestTreeView final List allTests = root.getAllTests(); for (AbstractTestProxy test : allTests) { if (test.isLeaf()) { - final DiffHyperlink provider = test.getDiffViewerProvider(); + final List provider = test.getDiffViewerProviders(); if (provider != null) { - providers.add(provider); + providers.addAll(provider); } } }