mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
test multiple failures: print last failure
This commit is contained in:
+6
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+40
@@ -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" +
|
||||
" <Click to see difference>\n" +
|
||||
"\n" +
|
||||
"stacktrace\n" +
|
||||
"\n" +
|
||||
"b\n" +
|
||||
"Expected :expected2\n" +
|
||||
"Actual :actual2\n" +
|
||||
" <Click to see difference>\n" +
|
||||
"\n" +
|
||||
"stacktrace\n" +
|
||||
"\n" +
|
||||
"c\n" +
|
||||
"stacktrace\n", printer.getAllOut());
|
||||
}
|
||||
|
||||
public void testTestFailed_ComparisonAssertion() {
|
||||
mySimpleTest.setStarted();
|
||||
mySimpleTest.setTestComparisonFailed("", "", "", "");
|
||||
|
||||
Reference in New Issue
Block a user