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 7c7097310444..bb566a29b1d6 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 @@ -441,19 +441,23 @@ public class SMTestProxy extends AbstractTestProxy { public void setTestFailed(@NotNull String localizedMessage, @Nullable String stackTrace, boolean testError) { setStacktraceIfNotSet(stackTrace); + TestFailedState failedState = new TestFailedState(localizedMessage, stackTrace); if (myState instanceof TestComparisionFailedState) { CompoundTestFailedState states = new CompoundTestFailedState(localizedMessage, stackTrace); states.addFailure((TestFailedState)myState); - final TestFailedState failedState = new TestFailedState(localizedMessage, stackTrace); states.addFailure(failedState); fireOnNewPrintable(failedState); myState = states; } + else if (myState instanceof CompoundTestFailedState) { + ((CompoundTestFailedState)myState).addFailure(failedState); + fireOnNewPrintable(failedState); + } else if (myState instanceof TestFailedState) { ((TestFailedState)myState).addError(localizedMessage, stackTrace, myPrinter); } else { - myState = testError ? new TestErrorState(localizedMessage, stackTrace) : new TestFailedState(localizedMessage, stackTrace); + myState = testError ? new TestErrorState(localizedMessage, stackTrace) : failedState; fireOnNewPrintable(myState); } } diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTestProxyTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTestProxyTest.java index 69d404a0bb0b..05b5458db4b1 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTestProxyTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTestProxyTest.java @@ -15,12 +15,18 @@ */ package com.intellij.execution.testframework.sm.runner; +import com.intellij.execution.filters.HyperlinkInfo; import com.intellij.execution.testframework.Filter; import com.intellij.execution.testframework.TestConsoleProperties; import com.intellij.execution.testframework.sm.runner.ui.MockPrinter; +import com.intellij.execution.testframework.stacktrace.DiffHyperlink; +import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.psi.search.GlobalSearchScope; import org.easymock.EasyMock; +import java.util.ArrayList; +import java.util.List; + import static com.intellij.execution.testframework.sm.runner.states.TestStateInfo.Magnitude; /** @@ -227,6 +233,40 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase { assertTrue(mySimpleTest.getMagnitudeInfo() == Magnitude.FAILED_INDEX); } + public void testMultipleAssertions() { + mySimpleTest.setStarted(); + mySimpleTest.setTestComparisonFailed("a", "stacktrace", "actual1", "expected1"); + mySimpleTest.setTestComparisonFailed("b", "stacktrace", "actual2", "expected2"); + mySimpleTest.setTestFailed("c", "stacktrace", false); + mySimpleTest.setFinished(); + + final MockPrinter printer = new MockPrinter(true) { + @Override + public void printHyperlink(String text, HyperlinkInfo info) { + print(text, ConsoleViewContentType.SYSTEM_OUTPUT); + } + }; + mySimpleTest.printOn(printer); + assertEquals("", printer.getStdOut()); + assertEquals("\n" + + "a\n" + + "Expected :expected1\n" + + "Actual :actual1\n" + + " \n" + + "\n" + + "stacktrace\n" + + "\n" + + "b\n" + + "Expected :expected2\n" + + "Actual :actual2\n" + + " \n" + + "\n" + + "stacktrace\n" + + "\n" + + "c\n" + + "stacktrace\n", printer.getAllOut()); + } + public void testTestFailed_ComparisonAssertion() { mySimpleTest.setStarted(); mySimpleTest.setTestComparisonFailed("", "", "", "");