add test for auto 'testFinished' event for 'testIgnored' (IDEA-CR-31598)

This commit is contained in:
Sergey Simonchik
2018-04-10 19:01:53 +03:00
parent 25bdd04542
commit 74fae70f41
2 changed files with 57 additions and 9 deletions
@@ -26,14 +26,16 @@ public class TestIgnoredEvent extends TreeNodeEvent {
private final String myStacktrace;
public TestIgnoredEvent(@NotNull String testName, @NotNull String ignoreComment, @Nullable String stacktrace) {
super(testName, null);
myIgnoreComment = ignoreComment;
myStacktrace = stacktrace;
this(testName, null, ignoreComment, stacktrace);
}
public TestIgnoredEvent(@NotNull TestIgnored testIgnored, @Nullable String stacktrace) {
super(testIgnored.getTestName(), TreeNodeEvent.getNodeId(testIgnored));
myIgnoreComment = testIgnored.getIgnoreComment();
this(testIgnored.getTestName(), TreeNodeEvent.getNodeId(testIgnored), testIgnored.getIgnoreComment(), stacktrace);
}
public TestIgnoredEvent(@Nullable String name, @Nullable String id, @Nullable String ignoreComment, @Nullable String stacktrace) {
super(name, id);
myIgnoreComment = ignoreComment;
myStacktrace = stacktrace;
}
@@ -15,23 +15,32 @@
*/
package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.testframework.sm.runner.events.TestFailedEvent;
import com.intellij.execution.testframework.sm.runner.events.TestStartedEvent;
import com.intellij.execution.testframework.sm.runner.events.TestSuiteStartedEvent;
import com.intellij.execution.testframework.sm.runner.events.TreeNodeEvent;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.execution.testframework.sm.runner.events.*;
import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView;
import com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm;
import com.intellij.openapi.util.Disposer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class GeneralIdBasedToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase {
private SMTRunnerConsoleView myConsole;
private GeneralIdBasedToSMTRunnerEventsConvertor myEventsProcessor;
private SMTestProxy.SMRootTestProxy myRootProxy;
private SMTestRunnerResultsForm myResultsViewer;
@Override
protected void setUp() throws Exception {
super.setUp();
TestConsoleProperties consoleProperties = createConsoleProperties();
myConsole = new SMTRunnerConsoleView(consoleProperties);
myConsole.initUI();
myResultsViewer = myConsole.getResultsViewer();
myRootProxy = new SMTestProxy.SMRootTestProxy();
myEventsProcessor = new GeneralIdBasedToSMTRunnerEventsConvertor(getProject(), myRootProxy, "test");
myEventsProcessor.addEventsListener(myResultsViewer);
myEventsProcessor.onStartTesting();
}
@@ -39,6 +48,7 @@ public class GeneralIdBasedToSMTRunnerEventsConvertorTest extends BaseSMTRunnerT
protected void tearDown() throws Exception {
try {
Disposer.dispose(myEventsProcessor);
Disposer.dispose(myConsole);
}
finally {
super.tearDown();
@@ -84,6 +94,27 @@ public class GeneralIdBasedToSMTRunnerEventsConvertorTest extends BaseSMTRunnerT
assertTrue(suiteProxy.isInProgress());
}
public void testIgnoredEvent() {
onSuiteStarted("Suite", null, "1", TreeNodeEvent.ROOT_NODE_ID);
SMTestProxy suite = validateSuite("1", "Suite", null, myRootProxy);
onTestStarted("testA", null, "A", "1", true);
SMTestProxy testA = validateTest("A", "testA", null, true, suite);
onTestIgnored("A");
validateTestIgnored("A", testA);
assertFalse(testA.isInProgress());
assertTrue(suite.isInProgress());
assertEquals(1, myResultsViewer.getFinishedTestCount());
onTestFinished("A", null);
assertEquals(1, myResultsViewer.getFinishedTestCount());
onTestStarted("testB", null, "B", "1", true);
SMTestProxy testB = validateTest("B", "testB", null, true, suite);
assertEquals(1, myResultsViewer.getFinishedTestCount());
onTestIgnored("B");
assertEquals(2, myResultsViewer.getFinishedTestCount());
validateTestIgnored("B", testB);
}
@NotNull
private SMTestProxy validateSuite(@NotNull String id,
@NotNull String expectedName,
@@ -129,6 +160,14 @@ public class GeneralIdBasedToSMTRunnerEventsConvertorTest extends BaseSMTRunnerT
return test;
}
private void validateTestIgnored(@NotNull String id, @NotNull SMTestProxy expectedTestProxy) {
SMTestProxy test = myEventsProcessor.findProxyById(id);
assertEquals(expectedTestProxy, test);
assertFalse(test.isSuite());
assertTrue(test.isFinal());
assertTrue(test.isIgnored());
}
private void onSuiteStarted(@NotNull String suiteName, @Nullable String metainfo, @NotNull String id, @NotNull String parentId) {
myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent(suiteName, id, parentId, null, metainfo, null, null, false));
}
@@ -141,9 +180,16 @@ public class GeneralIdBasedToSMTRunnerEventsConvertorTest extends BaseSMTRunnerT
myEventsProcessor.onTestStarted(new TestStartedEvent(testName, id, parentId, null, metainfo, null, null, running));
}
private void onTestFinished(@NotNull String id, @Nullable Long duration) {
myEventsProcessor.onTestFinished(new TestFinishedEvent(null, id, duration));
}
private void onTestFailed(@NotNull String id, @NotNull String errorMessage, int durationMillis) {
myEventsProcessor.onTestFailure(new TestFailedEvent(null, id, errorMessage, null, false, null,
null, null, null, false, false, durationMillis));
}
private void onTestIgnored(@NotNull String id) {
myEventsProcessor.onTestIgnored(new TestIgnoredEvent(null, id, null, null));
}
}