mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SM test runner event converter based on node id
This commit is contained in:
+27
-10
@@ -25,9 +25,7 @@ import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.execution.testframework.sm.runner.GeneralToSMTRunnerEventsConvertor;
|
||||
import com.intellij.execution.testframework.sm.runner.OutputToGeneralTestEventsConverter;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties;
|
||||
import com.intellij.execution.testframework.sm.runner.*;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerNotificationsHandler;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerUIActionsHandler;
|
||||
@@ -87,6 +85,16 @@ public class SMTestRunnerConnectionUtil {
|
||||
final RunnerSettings runnerSettings,
|
||||
final ConfigurationPerRunnerSettings configurationSettings,
|
||||
@Nullable final TestLocationProvider locator) {
|
||||
return createConsoleWithCustomLocator(testFrameworkName, consoleProperties, runnerSettings,
|
||||
configurationSettings, locator, false);
|
||||
}
|
||||
|
||||
public static BaseTestsOutputConsoleView createConsoleWithCustomLocator(@NotNull final String testFrameworkName,
|
||||
@NotNull final TestConsoleProperties consoleProperties,
|
||||
final RunnerSettings runnerSettings,
|
||||
final ConfigurationPerRunnerSettings configurationSettings,
|
||||
@Nullable final TestLocationProvider locator,
|
||||
final boolean idBasedTreeConstruction) {
|
||||
// Console
|
||||
final String splitterPropertyName = testFrameworkName + ".Splitter.Proportion";
|
||||
final SMTRunnerConsoleView console =
|
||||
@@ -97,7 +105,7 @@ public class SMTestRunnerConnectionUtil {
|
||||
super.attachToProcess(processHandler);
|
||||
attachEventsProcessors(consoleProperties, getResultsViewer(),
|
||||
getResultsViewer().getStatisticsPane(),
|
||||
processHandler, testFrameworkName, locator);
|
||||
processHandler, testFrameworkName, locator, idBasedTreeConstruction);
|
||||
}
|
||||
};
|
||||
console.setHelpId("reference.runToolWindow.testResultsTab");
|
||||
@@ -200,15 +208,24 @@ public class SMTestRunnerConnectionUtil {
|
||||
final StatisticsPanel statisticsPane,
|
||||
final ProcessHandler processHandler,
|
||||
@NotNull final String testFrameworkName,
|
||||
@Nullable final TestLocationProvider locator) {
|
||||
@Nullable final TestLocationProvider locator,
|
||||
boolean idBasedTreeConstruction) {
|
||||
//build messages consumer
|
||||
final OutputToGeneralTestEventsConverter outputConsumer = consoleProperties instanceof SMCustomMessagesParsing
|
||||
? ((SMCustomMessagesParsing)consoleProperties).createTestEventsConverter(testFrameworkName, consoleProperties)
|
||||
: new OutputToGeneralTestEventsConverter(testFrameworkName, consoleProperties);
|
||||
final OutputToGeneralTestEventsConverter outputConsumer;
|
||||
if (consoleProperties instanceof SMCustomMessagesParsing) {
|
||||
outputConsumer = ((SMCustomMessagesParsing)consoleProperties).createTestEventsConverter(testFrameworkName, consoleProperties);
|
||||
}
|
||||
else {
|
||||
outputConsumer = new OutputToGeneralTestEventsConverter(testFrameworkName, consoleProperties);
|
||||
}
|
||||
|
||||
//events processor
|
||||
final GeneralToSMTRunnerEventsConvertor eventsProcessor = new GeneralToSMTRunnerEventsConvertor(resultsViewer.getTestsRootNode(),
|
||||
testFrameworkName);
|
||||
final GeneralTestEventsProcessor eventsProcessor;
|
||||
if (idBasedTreeConstruction) {
|
||||
eventsProcessor = new GeneralIdBasedToSMTRunnerEventsConvertor(resultsViewer.getTestsRootNode(), testFrameworkName);
|
||||
} else {
|
||||
eventsProcessor = new GeneralToSMTRunnerEventsConvertor(resultsViewer.getTestsRootNode(), testFrameworkName);
|
||||
}
|
||||
if (locator != null) {
|
||||
eventsProcessor.setLocator(locator);
|
||||
}
|
||||
|
||||
+633
@@ -0,0 +1,633 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.execution.testframework.sm.SMRunnerUtil;
|
||||
import com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil;
|
||||
import com.intellij.execution.testframework.sm.runner.events.*;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.testIntegration.TestLocationProvider;
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
*/
|
||||
public class GeneralIdBasedToSMTRunnerEventsConvertor implements GeneralTestEventsProcessor {
|
||||
private static final Logger LOG = Logger.getInstance(GeneralIdBasedToSMTRunnerEventsConvertor.class.getName());
|
||||
|
||||
private final TIntObjectHashMap<Node> myNodeByIdMap = new TIntObjectHashMap<Node>();
|
||||
private final Set<Node> myRunningNodes = Sets.newHashSet();
|
||||
private final List<SMTRunnerEventsListener> myEventsListeners = new ArrayList<SMTRunnerEventsListener>();
|
||||
private final SMTestProxy.SMRootTestProxy myTestsRootProxy;
|
||||
private final Node myTestsRootNode;
|
||||
private final String myTestFrameworkName;
|
||||
private boolean myIsTestingFinished = false;
|
||||
private TestLocationProvider myLocator = null;
|
||||
|
||||
public GeneralIdBasedToSMTRunnerEventsConvertor(@NotNull SMTestProxy.SMRootTestProxy testsRootProxy,
|
||||
@NotNull String testFrameworkName) {
|
||||
myTestsRootProxy = testsRootProxy;
|
||||
myTestsRootNode = new Node(0, null, testsRootProxy);
|
||||
myTestFrameworkName = testFrameworkName;
|
||||
myNodeByIdMap.put(myTestsRootNode.getId(), myTestsRootNode);
|
||||
myRunningNodes.add(myTestsRootNode);
|
||||
}
|
||||
|
||||
public void setLocator(@NotNull TestLocationProvider customLocator) {
|
||||
myLocator = customLocator;
|
||||
}
|
||||
|
||||
public void addEventsListener(@NotNull SMTRunnerEventsListener listener) {
|
||||
myEventsListeners.add(listener);
|
||||
}
|
||||
|
||||
public void onStartTesting() {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
myTestsRootProxy.setStarted();
|
||||
|
||||
fireOnTestingStarted();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestsReporterAttached() {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
myTestsRootProxy.setTestsReporterAttached();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onFinishTesting() {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (myIsTestingFinished) {
|
||||
// has been already invoked!
|
||||
return;
|
||||
}
|
||||
myIsTestingFinished = true;
|
||||
|
||||
// We don't know whether process was destroyed by user
|
||||
// or it finished after all tests have been run
|
||||
// Lets assume, if at finish all suites except root suite are passed
|
||||
// then all is ok otherwise process was terminated by user
|
||||
if (myRunningNodes.size() == 1 && myRunningNodes.contains(myTestsRootNode)) {
|
||||
myTestsRootProxy.setFinished();
|
||||
} else {
|
||||
logProblem("Unexpected running nodes: " + myRunningNodes);
|
||||
myTestsRootProxy.setTerminated();
|
||||
}
|
||||
myNodeByIdMap.clear();
|
||||
myRunningNodes.clear();
|
||||
|
||||
fireOnTestingFinished();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onTestStarted(@NotNull final TestStartedEvent testStartedEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
doStartNode(testStartedEvent, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onSuiteStarted(@NotNull final TestSuiteStartedEvent suiteStartedEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
doStartNode(suiteStartedEvent, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doStartNode(@NotNull BaseStartedNodeEvent startedNodeEvent, boolean suite) {
|
||||
Node parentNode = findValidParentNode(startedNodeEvent);
|
||||
if (parentNode == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!validateNodeId(startedNodeEvent)) {
|
||||
return;
|
||||
}
|
||||
int nodeId = startedNodeEvent.getId();
|
||||
Node childNode = myNodeByIdMap.get(nodeId);
|
||||
if (childNode != null) {
|
||||
logProblem(startedNodeEvent + " has been already started: " + childNode + "!");
|
||||
return;
|
||||
}
|
||||
|
||||
SMTestProxy childProxy = new SMTestProxy(startedNodeEvent.getName(), suite, startedNodeEvent.getLocationUrl(), true);
|
||||
childNode = new Node(startedNodeEvent.getId(), parentNode, childProxy);
|
||||
myNodeByIdMap.put(nodeId, childNode);
|
||||
myRunningNodes.add(childNode);
|
||||
if (myLocator != null) {
|
||||
childProxy.setLocator(myLocator);
|
||||
}
|
||||
parentNode.getProxy().addChild(childProxy);
|
||||
|
||||
// progress started
|
||||
childProxy.setStarted();
|
||||
if (suite) {
|
||||
fireOnSuiteStarted(childProxy);
|
||||
} else {
|
||||
fireOnTestStarted(childProxy);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Node findValidParentNode(@NotNull BaseStartedNodeEvent startedNodeEvent) {
|
||||
int parentId = startedNodeEvent.getParentId();
|
||||
if (parentId < 0) {
|
||||
logProblem("Parent node id should be non-negative: " + startedNodeEvent + ".");
|
||||
return null;
|
||||
}
|
||||
Node parentNode = myNodeByIdMap.get(startedNodeEvent.getParentId());
|
||||
if (parentNode == null) {
|
||||
logProblem("Parent node is undefined for " + startedNodeEvent + ".");
|
||||
return null;
|
||||
}
|
||||
if (parentNode.getState() != State.RUNNING) {
|
||||
logProblem("Parent node should be running: " + parentNode + ", " + startedNodeEvent);
|
||||
return null;
|
||||
}
|
||||
return parentNode;
|
||||
}
|
||||
|
||||
public void onTestFinished(@NotNull final TestFinishedEvent testFinishedEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
doFinishNode(testFinishedEvent, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onSuiteFinished(@NotNull final TestSuiteFinishedEvent suiteFinishedEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
doFinishNode(suiteFinishedEvent, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doFinishNode(@NotNull TreeNodeEvent treeNodeEvent, boolean suite) {
|
||||
Node finishedNode = findNode(treeNodeEvent);
|
||||
if (finishedNode == null) {
|
||||
String nodeType = suite ? "Suite" : "Test";
|
||||
logProblem("Trying to finish not started " + nodeType + ": " + treeNodeEvent);
|
||||
return;
|
||||
}
|
||||
stopRunningNode(finishedNode, State.FINISHED, treeNodeEvent);
|
||||
finishedNode.getProxy().setFinished();
|
||||
if (suite) {
|
||||
fireOnSuiteFinished(finishedNode.getProxy());
|
||||
} else {
|
||||
fireOnTestFinished(finishedNode.getProxy());
|
||||
}
|
||||
}
|
||||
|
||||
public void onUncapturedOutput(@NotNull final String text, final Key outputType) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
Node activeNode = findActiveNode();
|
||||
SMTestProxy activeProxy = activeNode.getProxy();
|
||||
if (ProcessOutputTypes.STDERR.equals(outputType)) {
|
||||
activeProxy.addStdErr(text);
|
||||
} else if (ProcessOutputTypes.SYSTEM.equals(outputType)) {
|
||||
activeProxy.addSystemOutput(text);
|
||||
} else {
|
||||
activeProxy.addStdOutput(text, outputType);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onError(@NotNull final String localizedMessage,
|
||||
@Nullable final String stackTrace,
|
||||
final boolean isCritical) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
Node activeNode = findActiveNode();
|
||||
SMTestProxy activeProxy = activeNode.getProxy();
|
||||
activeProxy.addError(localizedMessage, stackTrace, isCritical);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onCustomProgressTestsCategory(@Nullable final String categoryName,
|
||||
final int testCount) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
fireOnCustomProgressTestsCategory(categoryName, testCount);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onCustomProgressTestStarted() {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
fireOnCustomProgressTestStarted();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onCustomProgressTestFailed() {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
fireOnCustomProgressTestFailed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onTestFailure(@NotNull final TestFailedEvent testFailedEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
Node node = findNode(testFailedEvent);
|
||||
if (node == null) {
|
||||
logProblem("Test wasn't started! " + testFailedEvent + ".");
|
||||
return;
|
||||
}
|
||||
stopRunningNode(node, State.FAILED, testFailedEvent);
|
||||
|
||||
SMTestProxy testProxy = node.getProxy();
|
||||
|
||||
String comparisonFailureActualText = testFailedEvent.getComparisonFailureActualText();
|
||||
String comparisonFailureExpectedText = testFailedEvent.getComparisonFailureExpectedText();
|
||||
String failureMessage = testFailedEvent.getLocalizedFailureMessage();
|
||||
String stackTrace = testFailedEvent.getStacktrace();
|
||||
if (comparisonFailureActualText != null && comparisonFailureExpectedText != null) {
|
||||
testProxy.setTestComparisonFailed(failureMessage, stackTrace,
|
||||
comparisonFailureActualText, comparisonFailureExpectedText);
|
||||
} else if (comparisonFailureActualText == null && comparisonFailureExpectedText == null) {
|
||||
testProxy.setTestFailed(failureMessage, stackTrace, testFailedEvent.isTestError());
|
||||
} else {
|
||||
logProblem("Comparison failure actual and expected texts should be both null or not null.\n"
|
||||
+ "Expected:\n"
|
||||
+ comparisonFailureExpectedText + "\n"
|
||||
+ "Actual:\n"
|
||||
+ comparisonFailureActualText);
|
||||
}
|
||||
|
||||
// fire event
|
||||
fireOnTestFailed(testProxy);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onTestIgnored(@NotNull final TestIgnoredEvent testIgnoredEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
Node node = findNode(testIgnoredEvent);
|
||||
if (node == null) {
|
||||
logProblem("Test wasn't started! " + testIgnoredEvent + ".");
|
||||
return;
|
||||
}
|
||||
stopRunningNode(node, State.IGNORED, testIgnoredEvent);
|
||||
|
||||
SMTestProxy testProxy = node.getProxy();
|
||||
testProxy.setTestIgnored(testIgnoredEvent.getIgnoreComment(), testIgnoredEvent.getStacktrace());
|
||||
|
||||
// fire event
|
||||
fireOnTestIgnored(testProxy);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onTestOutput(@NotNull final TestOutputEvent testOutputEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
Node node = findNode(testOutputEvent);
|
||||
if (node == null) {
|
||||
logProblem("Test wasn't started! But " + testOutputEvent + "!");
|
||||
return;
|
||||
}
|
||||
SMTestProxy testProxy = node.getProxy();
|
||||
|
||||
if (testOutputEvent.isStdOut()) {
|
||||
testProxy.addStdOutput(testOutputEvent.getText(), ProcessOutputTypes.STDOUT);
|
||||
} else {
|
||||
testProxy.addStdErr(testOutputEvent.getText());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onTestsCountInSuite(final int count) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
fireOnTestsCountInSuite(count);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean validateNodeId(@NotNull TreeNodeEvent treeNodeEvent) {
|
||||
int nodeId = treeNodeEvent.getId();
|
||||
if (nodeId <= 0) {
|
||||
logProblem("Node id should be positive: " + treeNodeEvent + ".");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Node findNode(@NotNull TreeNodeEvent treeNodeEvent) {
|
||||
if (!validateNodeId(treeNodeEvent)) {
|
||||
return null;
|
||||
}
|
||||
return myNodeByIdMap.get(treeNodeEvent.getId());
|
||||
}
|
||||
|
||||
private void fireOnTestingStarted() {
|
||||
for (SMTRunnerEventsListener listener : myEventsListeners) {
|
||||
listener.onTestingStarted(myTestsRootProxy);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnTestingFinished() {
|
||||
for (SMTRunnerEventsListener listener : myEventsListeners) {
|
||||
listener.onTestingFinished(myTestsRootProxy);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnTestsCountInSuite(final int count) {
|
||||
for (SMTRunnerEventsListener listener : myEventsListeners) {
|
||||
listener.onTestsCountInSuite(count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fireOnTestStarted(final SMTestProxy test) {
|
||||
for (SMTRunnerEventsListener listener : myEventsListeners) {
|
||||
listener.onTestStarted(test);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnTestFinished(final SMTestProxy test) {
|
||||
for (SMTRunnerEventsListener listener : myEventsListeners) {
|
||||
listener.onTestFinished(test);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnTestFailed(final SMTestProxy test) {
|
||||
for (SMTRunnerEventsListener listener : myEventsListeners) {
|
||||
listener.onTestFailed(test);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnTestIgnored(final SMTestProxy test) {
|
||||
for (SMTRunnerEventsListener listener : myEventsListeners) {
|
||||
listener.onTestIgnored(test);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnSuiteStarted(final SMTestProxy suite) {
|
||||
for (SMTRunnerEventsListener listener : myEventsListeners) {
|
||||
listener.onSuiteStarted(suite);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnSuiteFinished(final SMTestProxy suite) {
|
||||
for (SMTRunnerEventsListener listener : myEventsListeners) {
|
||||
listener.onSuiteFinished(suite);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fireOnCustomProgressTestsCategory(@Nullable final String categoryName, int testCount) {
|
||||
for (SMTRunnerEventsListener listener : myEventsListeners) {
|
||||
listener.onCustomProgressTestsCategory(categoryName, testCount);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnCustomProgressTestStarted() {
|
||||
for (SMTRunnerEventsListener listener : myEventsListeners) {
|
||||
listener.onCustomProgressTestStarted();
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnCustomProgressTestFailed() {
|
||||
for (SMTRunnerEventsListener listener : myEventsListeners) {
|
||||
listener.onCustomProgressTestFailed();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove listeners, etc
|
||||
*/
|
||||
public void dispose() {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
myEventsListeners.clear();
|
||||
|
||||
if (!myRunningNodes.isEmpty()) {
|
||||
Application application = ApplicationManager.getApplication();
|
||||
if (!application.isHeadlessEnvironment() && !application.isUnitTestMode()) {
|
||||
logProblem("Not all events were processed!");
|
||||
}
|
||||
}
|
||||
myRunningNodes.clear();
|
||||
myNodeByIdMap.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void stopRunningNode(@NotNull Node node, @NotNull State stoppedState, @NotNull TreeNodeEvent event) {
|
||||
if (stoppedState == State.RUNNING) {
|
||||
throw new RuntimeException("newState shouldn't be " + State.RUNNING);
|
||||
}
|
||||
// check if has been already processed
|
||||
if (node.getState() != State.RUNNING) {
|
||||
logProblem("Can't change state of already stopped node" + node + " to " + stoppedState + ", " + event + ".");
|
||||
return;
|
||||
}
|
||||
myRunningNodes.remove(node);
|
||||
node.setState(stoppedState);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Node findActiveNode() {
|
||||
List<Node> runningLeaves = Lists.newArrayListWithExpectedSize(1);
|
||||
for (Node node : myRunningNodes) {
|
||||
if (!node.hasRunningChildren()) {
|
||||
runningLeaves.add(node);
|
||||
}
|
||||
}
|
||||
if (runningLeaves.isEmpty()) {
|
||||
throw new RuntimeException("No running leaves found, running nodes: " + myRunningNodes);
|
||||
}
|
||||
if (runningLeaves.size() == 1) {
|
||||
return runningLeaves.iterator().next();
|
||||
}
|
||||
List<Node> commonPathToRoot = null;
|
||||
for (Node leaf : runningLeaves) {
|
||||
List<Node> pathToRoot = leaf.getAncestorsFromParentToRoot();
|
||||
if (commonPathToRoot == null) {
|
||||
commonPathToRoot = pathToRoot;
|
||||
} else {
|
||||
commonPathToRoot = intersectPathsToRoot(commonPathToRoot, pathToRoot);
|
||||
}
|
||||
}
|
||||
if (commonPathToRoot == null || commonPathToRoot.isEmpty()) {
|
||||
throw new RuntimeException("Unexpected common path to root: " + commonPathToRoot + ", running leaves: " + runningLeaves);
|
||||
}
|
||||
return commonPathToRoot.get(0);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<Node> intersectPathsToRoot(@NotNull List<Node> pathToRoot1, @NotNull List<Node> pathToRoot2) {
|
||||
final int minSize = Math.min(pathToRoot1.size(), pathToRoot2.size());
|
||||
final int shift1 = pathToRoot1.size() - minSize;
|
||||
final int shift2 = pathToRoot2.size() - minSize;
|
||||
int commonSize = 0;
|
||||
for (int i = 0; i < minSize; i++) {
|
||||
Node node1 = pathToRoot1.get(i + shift1);
|
||||
Node node2 = pathToRoot2.get(i + shift2);
|
||||
if (node1 == node2) {
|
||||
commonSize = minSize - i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pathToRoot1.subList(pathToRoot1.size() - commonSize, pathToRoot1.size());
|
||||
}
|
||||
|
||||
private static String getTestFrameworkPrefix(@NotNull String testFrameworkName) {
|
||||
return "[" + testFrameworkName + "] ";
|
||||
}
|
||||
|
||||
private void logProblem(@NotNull String msg) {
|
||||
logProblem(LOG, msg, myTestFrameworkName);
|
||||
}
|
||||
|
||||
private static void logProblem(@NotNull Logger log, @NotNull String msg, @NotNull String testFrameworkName) {
|
||||
logProblem(log, msg, SMTestRunnerConnectionUtil.isInDebugMode(), testFrameworkName);
|
||||
}
|
||||
|
||||
private static void logProblem(@NotNull Logger log, @NotNull String msg, boolean throwError, @NotNull String testFrameworkName) {
|
||||
final String text = getTestFrameworkPrefix(testFrameworkName) + msg;
|
||||
if (throwError) {
|
||||
log.error(text);
|
||||
}
|
||||
else {
|
||||
log.warn(text);
|
||||
}
|
||||
}
|
||||
|
||||
private enum State {
|
||||
RUNNING, FINISHED, FAILED, IGNORED
|
||||
}
|
||||
|
||||
private static class Node {
|
||||
private final int myId;
|
||||
private final Node myParentNode;
|
||||
private final SMTestProxy myProxy;
|
||||
private State myState = State.RUNNING;
|
||||
private int myRunningChildCount = 0;
|
||||
|
||||
Node(int id, @Nullable Node parentNode, @NotNull SMTestProxy proxy) {
|
||||
myId = id;
|
||||
myParentNode = parentNode;
|
||||
myProxy = proxy;
|
||||
if (myParentNode != null) {
|
||||
myParentNode.myRunningChildCount++;
|
||||
}
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return myId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Node getParentNode() {
|
||||
return myParentNode;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SMTestProxy getProxy() {
|
||||
return myProxy;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public State getState() {
|
||||
return myState;
|
||||
}
|
||||
|
||||
public void setState(@NotNull State state) {
|
||||
if (myState == State.RUNNING && state != State.RUNNING) {
|
||||
if (myParentNode != null) {
|
||||
myParentNode.myRunningChildCount--;
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("Attempt to change state from " + myState + " to " + state + ":" + toString());
|
||||
}
|
||||
myState = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Node node = (Node)o;
|
||||
|
||||
return myId == node.myId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return myId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" +
|
||||
"id=" + myId +
|
||||
", parentId=" + (myParentNode != null ? String.valueOf(myParentNode.getId()) : "<undefined>") +
|
||||
", name='" + myProxy.getName() +
|
||||
"', isSuite=" + myProxy.isSuite() +
|
||||
", state=" + myState +
|
||||
'}';
|
||||
}
|
||||
|
||||
public boolean hasRunningChildren() {
|
||||
return myRunningChildCount > 0;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<Node> getAncestorsFromParentToRoot() {
|
||||
List<Node> ancestors = Lists.newArrayList();
|
||||
Node parent = getParentNode();
|
||||
while (parent != null) {
|
||||
ancestors.add(parent);
|
||||
parent = parent.getParentNode();
|
||||
}
|
||||
return ancestors;
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-20
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
package com.intellij.execution.testframework.sm.runner;
|
||||
|
||||
import com.intellij.execution.testframework.sm.runner.events.*;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.testIntegration.TestLocationProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -29,33 +31,23 @@ import org.jetbrains.annotations.Nullable;
|
||||
* and name of test method
|
||||
*/
|
||||
public interface GeneralTestEventsProcessor extends Disposable {
|
||||
void onStartTesting();
|
||||
|
||||
void onTestsCountInSuite(final int count);
|
||||
|
||||
void onTestStarted(@NotNull final String testName,
|
||||
@Nullable final String locationUrl);
|
||||
void onTestStarted(@NotNull TestStartedEvent testStartedEvent);
|
||||
|
||||
void onTestFinished(@NotNull final String testName,
|
||||
final int duration);
|
||||
void onTestFinished(@NotNull TestFinishedEvent testFinishedEvent);
|
||||
|
||||
void onTestFailure(@NotNull final String testName,
|
||||
@NotNull final String localizedMessage,
|
||||
@Nullable final String stackTrace,
|
||||
final boolean testError,
|
||||
@Nullable final String comparisionFailureActualText,
|
||||
@Nullable final String comparisionFailureExpectedText);
|
||||
void onTestFailure(@NotNull TestFailedEvent testFailedEvent);
|
||||
|
||||
void onTestIgnored(@NotNull final String testName,
|
||||
@NotNull final String ignoreComment,
|
||||
@Nullable final String stackTrace);
|
||||
void onTestIgnored(@NotNull TestIgnoredEvent testIgnoredEvent);
|
||||
|
||||
void onTestOutput(@NotNull final String testName,
|
||||
@NotNull final String text,
|
||||
final boolean stdOut);
|
||||
void onTestOutput(@NotNull TestOutputEvent testOutputEvent);
|
||||
|
||||
void onSuiteStarted(@NotNull final String suiteName,
|
||||
@Nullable final String locationUrl);
|
||||
void onSuiteStarted(@NotNull TestSuiteStartedEvent suiteStartedEvent);
|
||||
|
||||
void onSuiteFinished(@NotNull final String suiteName);
|
||||
void onSuiteFinished(@NotNull TestSuiteFinishedEvent suiteFinishedEvent);
|
||||
|
||||
void onUncapturedOutput(@NotNull final String text,
|
||||
final Key outputType);
|
||||
@@ -76,4 +68,10 @@ public interface GeneralTestEventsProcessor extends Disposable {
|
||||
void onCustomProgressTestStarted();
|
||||
void onCustomProgressTestFailed();
|
||||
void onTestsReporterAttached();
|
||||
}
|
||||
|
||||
void setLocator(@NotNull TestLocationProvider locator);
|
||||
|
||||
void addEventsListener(@NotNull SMTRunnerEventsListener viewer);
|
||||
|
||||
void onFinishTesting();
|
||||
}
|
||||
|
||||
+32
-21
@@ -19,11 +19,13 @@ import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.sm.SMRunnerUtil;
|
||||
import com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil;
|
||||
import com.intellij.execution.testframework.sm.runner.events.*;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.testIntegration.TestLocationProvider;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
@@ -55,11 +57,11 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
|
||||
myTestFrameworkName = testFrameworkName;
|
||||
}
|
||||
|
||||
public void setLocator(TestLocationProvider customLocator) {
|
||||
public void setLocator(@NotNull TestLocationProvider customLocator) {
|
||||
myLocator = customLocator;
|
||||
}
|
||||
|
||||
public void addEventsListener(final SMTRunnerEventsListener listener) {
|
||||
public void addEventsListener(@NotNull final SMTRunnerEventsListener listener) {
|
||||
myEventsListeners.add(listener);
|
||||
}
|
||||
|
||||
@@ -111,10 +113,11 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
|
||||
});
|
||||
}
|
||||
|
||||
public void onTestStarted(@NotNull final String testName,
|
||||
@Nullable final String locationUrl) {
|
||||
public void onTestStarted(@NotNull final TestStartedEvent testStartedEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
final String testName = testStartedEvent.getName();
|
||||
final String locationUrl = testStartedEvent.getLocationUrl();
|
||||
final String fullName = getFullTestName(testName);
|
||||
|
||||
if (myRunningTestsFullNameToProxy.containsKey(fullName)) {
|
||||
@@ -146,9 +149,11 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
|
||||
});
|
||||
}
|
||||
|
||||
public void onSuiteStarted(@NotNull final String suiteName, @Nullable final String locationUrl) {
|
||||
public void onSuiteStarted(@NotNull final TestSuiteStartedEvent suiteStartedEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
final String suiteName = suiteStartedEvent.getName();
|
||||
final String locationUrl = suiteStartedEvent.getLocationUrl();
|
||||
final SMTestProxy parentSuite = getCurrentSuite();
|
||||
//new suite
|
||||
final SMTestProxy newSuite = new SMTestProxy(suiteName, true, locationUrl);
|
||||
@@ -168,10 +173,11 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
|
||||
});
|
||||
}
|
||||
|
||||
public void onTestFinished(@NotNull final String testName,
|
||||
final int duration) {
|
||||
public void onTestFinished(@NotNull final TestFinishedEvent testFinishedEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
final String testName = testFinishedEvent.getName();
|
||||
final int duration = testFinishedEvent.getDuration();
|
||||
final String fullTestName = getFullTestName(testName);
|
||||
final SMTestProxy testProxy = getProxyByFullTestName(fullTestName);
|
||||
|
||||
@@ -191,9 +197,10 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
|
||||
});
|
||||
}
|
||||
|
||||
public void onSuiteFinished(@NotNull final String suiteName) {
|
||||
public void onSuiteFinished(@NotNull final TestSuiteFinishedEvent suiteFinishedEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
final String suiteName = suiteFinishedEvent.getName();
|
||||
final SMTestProxy mySuite = mySuitesStack.popSuite(suiteName);
|
||||
if (mySuite != null) {
|
||||
mySuite.setFinished();
|
||||
@@ -257,14 +264,15 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
|
||||
});
|
||||
}
|
||||
|
||||
public void onTestFailure(@NotNull final String testName,
|
||||
@NotNull final String localizedMessage,
|
||||
@Nullable final String stackTrace,
|
||||
final boolean isTestError,
|
||||
@Nullable final String comparisionFailureActualText,
|
||||
@Nullable final String comparisionFailureExpectedText) {
|
||||
public void onTestFailure(@NotNull final TestFailedEvent testFailedEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
final String testName = ObjectUtils.assertNotNull(testFailedEvent.getName());
|
||||
final String localizedMessage = testFailedEvent.getLocalizedFailureMessage();
|
||||
final String stackTrace = testFailedEvent.getStacktrace();
|
||||
final boolean isTestError = testFailedEvent.isTestError();
|
||||
final String comparisionFailureActualText = testFailedEvent.getComparisonFailureActualText();
|
||||
final String comparisionFailureExpectedText = testFailedEvent.getComparisonFailureExpectedText();
|
||||
final boolean inDebugMode = SMTestRunnerConnectionUtil.isInDebugMode();
|
||||
|
||||
final String fullTestName = getFullTestName(testName);
|
||||
@@ -281,7 +289,7 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
|
||||
if (!myFailedTestsSet.contains(testProxy)) {
|
||||
// if hasn't been already reported
|
||||
// 1. report
|
||||
onTestStarted(testName, null);
|
||||
onTestStarted(new TestStartedEvent(testName, null));
|
||||
// 2. add failure
|
||||
testProxy = getProxyByFullTestName(fullTestName);
|
||||
}
|
||||
@@ -323,11 +331,12 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
|
||||
});
|
||||
}
|
||||
|
||||
public void onTestIgnored(@NotNull final String testName,
|
||||
@NotNull final String ignoreComment,
|
||||
@Nullable final String stackTrace) {
|
||||
public void onTestIgnored(@NotNull final TestIgnoredEvent testIgnoredEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
final String testName = ObjectUtils.assertNotNull(testIgnoredEvent.getName());
|
||||
final String ignoreComment = testIgnoredEvent.getIgnoreComment();
|
||||
final String stackTrace = testIgnoredEvent.getStacktrace();
|
||||
final String fullTestName = getFullTestName(testName);
|
||||
SMTestProxy testProxy = getProxyByFullTestName(fullTestName);
|
||||
if (testProxy == null) {
|
||||
@@ -341,7 +350,7 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
|
||||
} else {
|
||||
// try to fix
|
||||
// 1. report test opened
|
||||
onTestStarted(testName, null);
|
||||
onTestStarted(new TestStartedEvent(testName, null));
|
||||
|
||||
// 2. report failure
|
||||
testProxy = getProxyByFullTestName(fullTestName);
|
||||
@@ -359,10 +368,12 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
|
||||
});
|
||||
}
|
||||
|
||||
public void onTestOutput(@NotNull final String testName,
|
||||
@NotNull final String text, final boolean stdOut) {
|
||||
public void onTestOutput(@NotNull final TestOutputEvent testOutputEvent) {
|
||||
SMRunnerUtil.addToInvokeLater(new Runnable() {
|
||||
public void run() {
|
||||
final String testName = testOutputEvent.getName();
|
||||
final String text = testOutputEvent.getText();
|
||||
final boolean stdOut = testOutputEvent.isStdOut();
|
||||
final String fullTestName = getFullTestName(testName);
|
||||
final SMTestProxy testProxy = getProxyByFullTestName(fullTestName);
|
||||
if (testProxy == null) {
|
||||
|
||||
+33
-57
@@ -17,6 +17,7 @@ package com.intellij.execution.testframework.sm.runner;
|
||||
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.execution.testframework.sm.runner.events.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -41,13 +42,11 @@ import static com.intellij.execution.testframework.sm.runner.GeneralToSMTRunnerE
|
||||
public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer {
|
||||
private static final Logger LOG = Logger.getInstance(OutputToGeneralTestEventsConverter.class.getName());
|
||||
|
||||
private static final String TEAMCITY_SERVICE_MESSAGE_PREFIX = "##teamcity[";
|
||||
|
||||
private GeneralTestEventsProcessor myProcessor;
|
||||
private final MyServiceMessageVisitor myServiceMessageVisitor;
|
||||
private final String myTestFrameworkName;
|
||||
|
||||
private OutputLineSplitter mySplitter;
|
||||
private final OutputLineSplitter mySplitter;
|
||||
private boolean myPendingLineBreakFlag;
|
||||
|
||||
public OutputToGeneralTestEventsConverter(@NotNull final String testFrameworkName,
|
||||
@@ -63,7 +62,7 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
|
||||
};
|
||||
}
|
||||
|
||||
public void setProcessor(final GeneralTestEventsProcessor processor) {
|
||||
public void setProcessor(@Nullable final GeneralTestEventsProcessor processor) {
|
||||
myProcessor = processor;
|
||||
}
|
||||
|
||||
@@ -142,52 +141,38 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
|
||||
}
|
||||
|
||||
|
||||
private void fireOnTestStarted(final String testName, @Nullable final String locationUrl) {
|
||||
assertNotNull(testName);
|
||||
|
||||
private void fireOnTestStarted(@NotNull TestStartedEvent testStartedEvent) {
|
||||
// local variable is used to prevent concurrent modification
|
||||
final GeneralTestEventsProcessor processor = myProcessor;
|
||||
if (processor != null) {
|
||||
processor.onTestStarted(testName, locationUrl);
|
||||
processor.onTestStarted(testStartedEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnTestFailure(final String testName,
|
||||
final String localizedMessage, final String stackTrace,
|
||||
final boolean isTestError,
|
||||
@Nullable final String comparisionFailureActualText,
|
||||
@Nullable final String comparisionFailureExpectedText) {
|
||||
assertNotNull(testName);
|
||||
assertNotNull(localizedMessage);
|
||||
private void fireOnTestFailure(@NotNull TestFailedEvent testFailedEvent) {
|
||||
assertNotNull(testFailedEvent.getLocalizedFailureMessage());
|
||||
|
||||
// local variable is used to prevent concurrent modification
|
||||
final GeneralTestEventsProcessor processor = myProcessor;
|
||||
if (processor != null) {
|
||||
processor.onTestFailure(testName, localizedMessage, stackTrace, isTestError,
|
||||
comparisionFailureActualText,
|
||||
comparisionFailureExpectedText);
|
||||
processor.onTestFailure(testFailedEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnTestIgnored(final String testName, final String ignoreComment,
|
||||
@Nullable final String details) {
|
||||
assertNotNull(testName);
|
||||
assertNotNull(ignoreComment);
|
||||
private void fireOnTestIgnored(@NotNull TestIgnoredEvent testIgnoredEvent) {
|
||||
|
||||
// local variable is used to prevent concurrent modification
|
||||
final GeneralTestEventsProcessor processor = myProcessor;
|
||||
if (processor != null) {
|
||||
processor.onTestIgnored(testName, ignoreComment, details);
|
||||
processor.onTestIgnored(testIgnoredEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnTestFinished(final String testName, final int duration) {
|
||||
assertNotNull(testName);
|
||||
|
||||
private void fireOnTestFinished(@NotNull TestFinishedEvent testFinishedEvent) {
|
||||
// local variable is used to prevent concurrent modification
|
||||
final GeneralTestEventsProcessor processor = myProcessor;
|
||||
if (processor != null) {
|
||||
processor.onTestFinished(testName, duration);
|
||||
processor.onTestFinished(testFinishedEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,14 +209,11 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnTestOutput(final String testName, final String text, final boolean stdOut) {
|
||||
assertNotNull(testName);
|
||||
assertNotNull(text);
|
||||
|
||||
private void fireOnTestOutput(@NotNull TestOutputEvent testOutputEvent) {
|
||||
// local variable is used to prevent concurrent modification
|
||||
final GeneralTestEventsProcessor processor = myProcessor;
|
||||
if (processor != null) {
|
||||
processor.onTestOutput(testName, text, stdOut);
|
||||
processor.onTestOutput(testOutputEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,23 +239,19 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnSuiteStarted(final String suiteName, @Nullable final String locationUrl) {
|
||||
assertNotNull(suiteName);
|
||||
|
||||
private void fireOnSuiteStarted(@NotNull TestSuiteStartedEvent suiteStartedEvent) {
|
||||
// local variable is used to prevent concurrent modification
|
||||
final GeneralTestEventsProcessor processor = myProcessor;
|
||||
if (processor != null) {
|
||||
processor.onSuiteStarted(suiteName, locationUrl);
|
||||
processor.onSuiteStarted(suiteStartedEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnSuiteFinished(final String suiteName) {
|
||||
assertNotNull(suiteName);
|
||||
|
||||
private void fireOnSuiteFinished(@NotNull TestSuiteFinishedEvent nodeFinishedEvent) {
|
||||
// local variable is used to prevent concurrent modification
|
||||
final GeneralTestEventsProcessor processor = myProcessor;
|
||||
if (processor != null) {
|
||||
processor.onSuiteFinished(suiteName);
|
||||
processor.onSuiteFinished(nodeFinishedEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,7 +299,8 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
|
||||
|
||||
public void visitTestSuiteStarted(@NotNull final TestSuiteStarted suiteStarted) {
|
||||
final String locationUrl = fetchTestLocation(suiteStarted);
|
||||
fireOnSuiteStarted(suiteStarted.getSuiteName(), locationUrl);
|
||||
TestSuiteStartedEvent suiteStartedEvent = new TestSuiteStartedEvent(suiteStarted, locationUrl);
|
||||
fireOnSuiteStarted(suiteStartedEvent);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -343,7 +322,8 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
|
||||
}
|
||||
|
||||
public void visitTestSuiteFinished(@NotNull final TestSuiteFinished suiteFinished) {
|
||||
fireOnSuiteFinished(suiteFinished.getSuiteName());
|
||||
TestSuiteFinishedEvent finishedEvent = new TestSuiteFinishedEvent(suiteFinished);
|
||||
fireOnSuiteFinished(finishedEvent);
|
||||
}
|
||||
|
||||
public void visitTestStarted(@NotNull final TestStarted testStarted) {
|
||||
@@ -351,7 +331,8 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
|
||||
// final String locationUrl = testStarted.getLocationHint();
|
||||
|
||||
final String locationUrl = testStarted.getAttributes().get(ATTR_KEY_LOCATION_URL);
|
||||
fireOnTestStarted(testStarted.getTestName(), locationUrl);
|
||||
TestStartedEvent testStartedEvent = new TestStartedEvent(testStarted, locationUrl);
|
||||
fireOnTestStarted(testStartedEvent);
|
||||
}
|
||||
|
||||
public void visitTestFinished(@NotNull final TestFinished testFinished) {
|
||||
@@ -368,31 +349,27 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
|
||||
duration = convertToInt(durationStr, testFinished);
|
||||
}
|
||||
|
||||
fireOnTestFinished(testFinished.getTestName(), duration);
|
||||
TestFinishedEvent testFinishedEvent = new TestFinishedEvent(testFinished, duration);
|
||||
fireOnTestFinished(testFinishedEvent);
|
||||
}
|
||||
|
||||
public void visitTestIgnored(@NotNull final TestIgnored testIgnored) {
|
||||
final String details = testIgnored.getAttributes().get(ATTR_KEY_STACKTRACE_DETAILS);
|
||||
fireOnTestIgnored(testIgnored.getTestName(), testIgnored.getIgnoreComment(), details);
|
||||
final String stacktrace = testIgnored.getAttributes().get(ATTR_KEY_STACKTRACE_DETAILS);
|
||||
fireOnTestIgnored(new TestIgnoredEvent(testIgnored, stacktrace));
|
||||
}
|
||||
|
||||
public void visitTestStdOut(@NotNull final TestStdOut testStdOut) {
|
||||
fireOnTestOutput(testStdOut.getTestName(), testStdOut.getStdOut(), true);
|
||||
fireOnTestOutput(new TestOutputEvent(testStdOut, testStdOut.getStdOut(), true));
|
||||
}
|
||||
|
||||
public void visitTestStdErr(@NotNull final TestStdErr testStdErr) {
|
||||
fireOnTestOutput(testStdErr.getTestName(), testStdErr.getStdErr(), false);
|
||||
fireOnTestOutput(new TestOutputEvent(testStdErr.getTestName(), testStdErr.getStdErr(), false));
|
||||
}
|
||||
|
||||
public void visitTestFailed(@NotNull final TestFailed testFailed) {
|
||||
final boolean isTestError = testFailed.getAttributes().get(ATTR_KEY_TEST_ERROR) != null;
|
||||
|
||||
fireOnTestFailure(testFailed.getTestName(),
|
||||
testFailed.getFailureMessage(),
|
||||
testFailed.getStacktrace(),
|
||||
isTestError,
|
||||
testFailed.getActual(),
|
||||
testFailed.getExpected());
|
||||
final boolean testError = testFailed.getAttributes().get(ATTR_KEY_TEST_ERROR) != null;
|
||||
TestFailedEvent testFailedEvent = new TestFailedEvent(testFailed, testError);
|
||||
fireOnTestFailure(testFailedEvent);
|
||||
}
|
||||
|
||||
public void visitPublishArtifacts(@NotNull final PublishArtifacts publishArtifacts) {
|
||||
@@ -425,7 +402,6 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
|
||||
|
||||
@Override
|
||||
public void visitMessageWithStatus(@NotNull Message msg) {
|
||||
final String name = msg.getMessageName();
|
||||
final Map<String, String> msgAttrs = msg.getAttributes();
|
||||
|
||||
final String text = msgAttrs.get(ATTR_KEY_TEXT);
|
||||
|
||||
@@ -61,12 +61,20 @@ public class SMTestProxy extends AbstractTestProxy {
|
||||
private boolean myIsEmptyIsCached = false; // is used for separating unknown and unset values
|
||||
private boolean myIsEmpty = true;
|
||||
TestLocationProvider myCustomLocator = null;
|
||||
private final boolean myPreservePresentableName;
|
||||
|
||||
public SMTestProxy(final String testName, final boolean isSuite,
|
||||
@Nullable final String locationUrl) {
|
||||
this(testName, isSuite, locationUrl, false);
|
||||
}
|
||||
|
||||
public SMTestProxy(final String testName, final boolean isSuite,
|
||||
@Nullable final String locationUrl,
|
||||
boolean preservePresentableName) {
|
||||
myName = testName;
|
||||
myIsSuite = isSuite;
|
||||
myLocationUrl = locationUrl;
|
||||
myPreservePresentableName = preservePresentableName;
|
||||
}
|
||||
|
||||
public void setLocator(@NotNull TestLocationProvider locator) {
|
||||
@@ -470,6 +478,9 @@ public class SMTestProxy extends AbstractTestProxy {
|
||||
|
||||
@NotNull
|
||||
public String getPresentableName() {
|
||||
if (myPreservePresentableName) {
|
||||
return TestsPresentationUtil.getPresentableNameTrimmedOnly(this);
|
||||
}
|
||||
return TestsPresentationUtil.getPresentableName(this);
|
||||
}
|
||||
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.events;
|
||||
|
||||
import jetbrains.buildServer.messages.serviceMessages.MessageWithAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
*/
|
||||
public abstract class BaseStartedNodeEvent extends TreeNodeEvent {
|
||||
|
||||
private final int myParentId;
|
||||
private final String myLocationUrl;
|
||||
|
||||
protected BaseStartedNodeEvent(@NotNull String name,
|
||||
int id,
|
||||
int parentId,
|
||||
@Nullable final String locationUrl) {
|
||||
super(name, id);
|
||||
myParentId = parentId;
|
||||
myLocationUrl = locationUrl;
|
||||
validate();
|
||||
}
|
||||
|
||||
private void validate() {
|
||||
if (myParentId < -1) {
|
||||
fail("parentId should be greater than -2");
|
||||
}
|
||||
if (getId() == -1 ^ myParentId == -1) {
|
||||
fail("id and parentId should be -1 or non-negative");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return parent node id (non-negative integer), or -1 if undefined
|
||||
*/
|
||||
public int getParentId() {
|
||||
return myParentId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLocationUrl() {
|
||||
return myLocationUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendToStringInfo(@NotNull StringBuilder buf) {
|
||||
append(buf, "parentId", myParentId);
|
||||
append(buf, "locationUrl", myLocationUrl);
|
||||
}
|
||||
|
||||
public static int getParentNodeId(@NotNull MessageWithAttributes message) {
|
||||
return TreeNodeEvent.getIntAttribute(message, "parentNodeId");
|
||||
}
|
||||
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.events;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import jetbrains.buildServer.messages.serviceMessages.TestFailed;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
*/
|
||||
public class TestFailedEvent extends TreeNodeEvent {
|
||||
|
||||
private final String myLocalizedFailureMessage;
|
||||
private final String myStacktrace;
|
||||
private final boolean myTestError;
|
||||
private final String myComparisonFailureActualText;
|
||||
private final String myComparisonFailureExpectedText;
|
||||
|
||||
public TestFailedEvent(@NotNull TestFailed testFailed, boolean testError) {
|
||||
super(testFailed.getTestName(), TreeNodeEvent.getNodeId(testFailed));
|
||||
myLocalizedFailureMessage = Preconditions.checkNotNull(testFailed.getFailureMessage());
|
||||
myStacktrace = testFailed.getStacktrace();
|
||||
myTestError = testError;
|
||||
myComparisonFailureActualText = testFailed.getActual();
|
||||
myComparisonFailureExpectedText = testFailed.getExpected();
|
||||
}
|
||||
|
||||
public TestFailedEvent(@NotNull String testName,
|
||||
@NotNull String localizedFailureMessage,
|
||||
@Nullable String stackTrace,
|
||||
boolean testError,
|
||||
@Nullable String comparisonFailureActualText,
|
||||
@Nullable String comparisonFailureExpectedText) {
|
||||
super(testName, -1);
|
||||
myLocalizedFailureMessage = Preconditions.checkNotNull(localizedFailureMessage);
|
||||
myStacktrace = stackTrace;
|
||||
myTestError = testError;
|
||||
myComparisonFailureActualText = comparisonFailureActualText;
|
||||
myComparisonFailureExpectedText = comparisonFailureExpectedText;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getLocalizedFailureMessage() {
|
||||
return myLocalizedFailureMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getStacktrace() {
|
||||
return myStacktrace;
|
||||
}
|
||||
|
||||
public boolean isTestError() {
|
||||
return myTestError;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getComparisonFailureActualText() {
|
||||
return myComparisonFailureActualText;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getComparisonFailureExpectedText() {
|
||||
return myComparisonFailureExpectedText;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendToStringInfo(@NotNull StringBuilder buf) {
|
||||
append(buf, "localizedFailureMessage", myLocalizedFailureMessage);
|
||||
append(buf, "stacktrace", myStacktrace);
|
||||
append(buf, "isTestError", myTestError);
|
||||
append(buf, "comparisonFailureActualText", myComparisonFailureActualText);
|
||||
append(buf, "comparisonFailureExpectedText", myComparisonFailureExpectedText);
|
||||
}
|
||||
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.events;
|
||||
|
||||
import jetbrains.buildServer.messages.serviceMessages.TestFinished;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
*/
|
||||
public class TestFinishedEvent extends TreeNodeEvent {
|
||||
|
||||
private final int myDuration;
|
||||
|
||||
public TestFinishedEvent(@NotNull TestFinished testFinished, int duration) {
|
||||
this(testFinished.getTestName(), TreeNodeEvent.getNodeId(testFinished), duration);
|
||||
}
|
||||
|
||||
public TestFinishedEvent(@Nullable String name, int id, int duration) {
|
||||
super(name, id);
|
||||
myDuration = duration;
|
||||
}
|
||||
|
||||
public TestFinishedEvent(@NotNull String name, int duration) {
|
||||
this(name, -1, duration);
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return myDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendToStringInfo(@NotNull StringBuilder buf) {
|
||||
append(buf, "duration", myDuration);
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.events;
|
||||
|
||||
import jetbrains.buildServer.messages.serviceMessages.TestIgnored;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
*/
|
||||
public class TestIgnoredEvent extends TreeNodeEvent {
|
||||
private final String myIgnoreComment;
|
||||
private final String myStacktrace;
|
||||
|
||||
public TestIgnoredEvent(@NotNull String testName, @NotNull String ignoreComment, @Nullable String stacktrace) {
|
||||
super(testName, -1);
|
||||
myIgnoreComment = ignoreComment;
|
||||
myStacktrace = stacktrace;
|
||||
}
|
||||
|
||||
public TestIgnoredEvent(@NotNull TestIgnored testIgnored, @Nullable String stacktrace) {
|
||||
super(testIgnored.getTestName(), TreeNodeEvent.getNodeId(testIgnored));
|
||||
myIgnoreComment = testIgnored.getIgnoreComment();
|
||||
myStacktrace = stacktrace;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getIgnoreComment() {
|
||||
return myIgnoreComment;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getStacktrace() {
|
||||
return myStacktrace;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendToStringInfo(@NotNull StringBuilder buf) {
|
||||
append(buf, "ignoreComment", myIgnoreComment);
|
||||
append(buf, "stacktrace", myStacktrace);
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.events;
|
||||
|
||||
import jetbrains.buildServer.messages.serviceMessages.BaseTestMessage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
*/
|
||||
public class TestOutputEvent extends TreeNodeEvent {
|
||||
|
||||
private final String myText;
|
||||
private final boolean myStdOut;
|
||||
|
||||
public TestOutputEvent(@NotNull BaseTestMessage message, @NotNull String text, boolean stdOut) {
|
||||
super(message.getTestName(), TreeNodeEvent.getNodeId(message));
|
||||
myText = text;
|
||||
myStdOut = stdOut;
|
||||
}
|
||||
|
||||
public TestOutputEvent(@NotNull String testName, @NotNull String text, boolean stdOut) {
|
||||
super(testName, -1);
|
||||
myText = text;
|
||||
myStdOut = stdOut;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getText() {
|
||||
return myText;
|
||||
}
|
||||
|
||||
public boolean isStdOut() {
|
||||
return myStdOut;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendToStringInfo(@NotNull StringBuilder buf) {
|
||||
append(buf, "text", myText);
|
||||
append(buf, "stdOut", myStdOut);
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.events;
|
||||
|
||||
import jetbrains.buildServer.messages.serviceMessages.TestStarted;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
*/
|
||||
public class TestStartedEvent extends BaseStartedNodeEvent {
|
||||
|
||||
public TestStartedEvent(@NotNull TestStarted testStarted,
|
||||
@Nullable String locationUrl) {
|
||||
super(testStarted.getTestName(), TreeNodeEvent.getNodeId(testStarted),
|
||||
getParentNodeId(testStarted), locationUrl);
|
||||
}
|
||||
|
||||
public TestStartedEvent(@NotNull String name, @Nullable String locationUrl) {
|
||||
super(name, -1, -1, locationUrl);
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.events;
|
||||
|
||||
import jetbrains.buildServer.messages.serviceMessages.TestSuiteFinished;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
*/
|
||||
public class TestSuiteFinishedEvent extends TreeNodeEvent {
|
||||
|
||||
public TestSuiteFinishedEvent(@NotNull TestSuiteFinished suiteFinished) {
|
||||
super(suiteFinished.getSuiteName(), TreeNodeEvent.getNodeId(suiteFinished));
|
||||
}
|
||||
|
||||
public TestSuiteFinishedEvent(@NotNull String name) {
|
||||
super(name, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendToStringInfo(@NotNull StringBuilder buf) {
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.events;
|
||||
|
||||
import jetbrains.buildServer.messages.serviceMessages.TestSuiteStarted;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
*/
|
||||
public class TestSuiteStartedEvent extends BaseStartedNodeEvent {
|
||||
|
||||
public TestSuiteStartedEvent(@NotNull TestSuiteStarted suiteStarted,
|
||||
@Nullable String locationUrl) {
|
||||
super(suiteStarted.getSuiteName(), TreeNodeEvent.getNodeId(suiteStarted),
|
||||
getParentNodeId(suiteStarted), locationUrl);
|
||||
}
|
||||
|
||||
public TestSuiteStartedEvent(@NotNull String name, @Nullable String locationUrl) {
|
||||
super(name, -1, -1, locationUrl);
|
||||
}
|
||||
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.events;
|
||||
|
||||
import jetbrains.buildServer.messages.serviceMessages.MessageWithAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
*/
|
||||
public abstract class TreeNodeEvent {
|
||||
|
||||
private final String myName;
|
||||
private final int myId;
|
||||
|
||||
public TreeNodeEvent(@Nullable String name, int id) {
|
||||
myName = name;
|
||||
myId = id;
|
||||
validate();
|
||||
}
|
||||
|
||||
private void validate() {
|
||||
if (myId < -1) {
|
||||
fail("id should be greater than -2");
|
||||
}
|
||||
if (myName != null && myName.isEmpty()) {
|
||||
fail("Tree node name is empty");
|
||||
}
|
||||
}
|
||||
|
||||
protected void fail(@NotNull String message) {
|
||||
throw new IllegalStateException(message + ", " + toString());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return tree node id (non-negative integer), or -1 if undefined
|
||||
*/
|
||||
public int getId() {
|
||||
return myId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
StringBuilder buf = new StringBuilder(getClass().getSimpleName() + "{");
|
||||
append(buf, "name", myName);
|
||||
append(buf, "id", myId);
|
||||
appendToStringInfo(buf);
|
||||
// drop last 2 chars: ', '
|
||||
buf.setLength(buf.length() - 2);
|
||||
buf.append("}");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
protected abstract void appendToStringInfo(@NotNull StringBuilder buf);
|
||||
|
||||
protected static void append(@NotNull StringBuilder buffer,
|
||||
@NotNull String key, @Nullable Object value) {
|
||||
if (value != null) {
|
||||
buffer.append(key).append("=");
|
||||
if (value instanceof String) {
|
||||
buffer.append("'").append(value).append("'");
|
||||
}
|
||||
else {
|
||||
buffer.append(String.valueOf(value));
|
||||
}
|
||||
buffer.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNodeId(@NotNull MessageWithAttributes message) {
|
||||
return getIntAttribute(message, "nodeId");
|
||||
}
|
||||
|
||||
public static int getIntAttribute(@NotNull MessageWithAttributes message, @NotNull String key) {
|
||||
String value = message.getAttributes().get(key);
|
||||
if (value == null) {
|
||||
return -1;
|
||||
}
|
||||
return Integer.parseInt(value);
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -226,6 +226,18 @@ public class TestsPresentationUtil {
|
||||
return presentationCandidate;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getPresentableNameTrimmedOnly(@NotNull SMTestProxy testProxy) {
|
||||
String name = testProxy.getName();
|
||||
if (name != null) {
|
||||
name = name.trim();
|
||||
}
|
||||
if (name == null || name.isEmpty()) {
|
||||
name = NO_NAME_TEST;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Icon getIcon(final SMTestProxy testProxy,
|
||||
final TestConsoleProperties consoleProperties) {
|
||||
|
||||
+26
-25
@@ -18,6 +18,7 @@ package com.intellij.execution.testframework.sm.runner;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.execution.testframework.sm.Marker;
|
||||
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.SMTRunnerTestTreeView;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm;
|
||||
@@ -125,7 +126,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
|
||||
public void testOnTestFailure() {
|
||||
onTestStarted("some_test");
|
||||
myEventsProcessor.onTestFailure("some_test", "", "", false, null, null);
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("some_test", "", "", false, null, null));
|
||||
|
||||
final String fullName = myEventsProcessor.getFullTestName("some_test");
|
||||
final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName);
|
||||
@@ -136,7 +137,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
|
||||
public void testOnTestComparisionFailure() {
|
||||
onTestStarted("some_test");
|
||||
myEventsProcessor.onTestFailure("some_test", "", "", false, "actual", "expected");
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("some_test", "", "", false, "actual", "expected"));
|
||||
|
||||
final String fullName = myEventsProcessor.getFullTestName("some_test");
|
||||
final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName);
|
||||
@@ -147,8 +148,8 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
|
||||
public void testOnTestFailure_Twice() {
|
||||
onTestStarted("some_test");
|
||||
myEventsProcessor.onTestFailure("some_test", "", "", false, null, null);
|
||||
myEventsProcessor.onTestFailure("some_test", "", "", false, null, null);
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("some_test", "", "", false, null, null));
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("some_test", "", "", false, null, null));
|
||||
|
||||
assertEquals(1, myEventsProcessor.getRunningTestsQuantity());
|
||||
assertEquals(1, myEventsProcessor.getFailedTestsSet().size());
|
||||
@@ -156,7 +157,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
|
||||
public void testOnTestError() {
|
||||
onTestStarted("some_test");
|
||||
myEventsProcessor.onTestFailure("some_test", "", "", true, null, null);
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("some_test", "", "", true, null, null));
|
||||
|
||||
final String fullName = myEventsProcessor.getFullTestName("some_test");
|
||||
final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName);
|
||||
@@ -167,7 +168,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
|
||||
public void testOnTestIgnored() {
|
||||
onTestStarted("some_test");
|
||||
myEventsProcessor.onTestIgnored("some_test", "", null);
|
||||
myEventsProcessor.onTestIgnored(new TestIgnoredEvent("some_test", "", null));
|
||||
|
||||
final String fullName = myEventsProcessor.getFullTestName("some_test");
|
||||
final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName);
|
||||
@@ -180,7 +181,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
onTestStarted("some_test");
|
||||
final String fullName = myEventsProcessor.getFullTestName("some_test");
|
||||
final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName);
|
||||
myEventsProcessor.onTestFinished("some_test", 10);
|
||||
myEventsProcessor.onTestFinished(new TestFinishedEvent("some_test", 10));
|
||||
|
||||
assertEquals(0, myEventsProcessor.getRunningTestsQuantity());
|
||||
assertEquals(0, myEventsProcessor.getFailedTestsSet().size());
|
||||
@@ -224,8 +225,8 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
|
||||
public void testOnFinishedTesting_WithFailure() {
|
||||
onTestStarted("test");
|
||||
myEventsProcessor.onTestFailure("test", "", "", false, null, null);
|
||||
myEventsProcessor.onTestFinished("test", 10);
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("test", "", "", false, null, null));
|
||||
myEventsProcessor.onTestFinished(new TestFinishedEvent("test", 10));
|
||||
myEventsProcessor.onFinishTesting();
|
||||
|
||||
//Tree
|
||||
@@ -240,8 +241,8 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
|
||||
public void testOnFinishedTesting_WithError() {
|
||||
onTestStarted("test");
|
||||
myEventsProcessor.onTestFailure("test", "", "", true, null, null);
|
||||
myEventsProcessor.onTestFinished("test", 10);
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("test", "", "", true, null, null));
|
||||
myEventsProcessor.onTestFinished(new TestFinishedEvent("test", 10));
|
||||
myEventsProcessor.onFinishTesting();
|
||||
|
||||
//Tree
|
||||
@@ -256,8 +257,8 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
|
||||
public void testOnFinishedTesting_WithIgnored() {
|
||||
onTestStarted("test");
|
||||
myEventsProcessor.onTestIgnored("test", "", null);
|
||||
myEventsProcessor.onTestFinished("test", 10);
|
||||
myEventsProcessor.onTestIgnored(new TestIgnoredEvent("test", "", null));
|
||||
myEventsProcessor.onTestFinished(new TestFinishedEvent("test", 10));
|
||||
myEventsProcessor.onFinishTesting();
|
||||
|
||||
//Tree
|
||||
@@ -302,18 +303,18 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
assertEquals("suite3", test2.getParent().getName());
|
||||
assertEquals("suite2", test2.getParent().getParent().getName());
|
||||
|
||||
myEventsProcessor.onTestFinished("test2", 10);
|
||||
myEventsProcessor.onTestFinished(new TestFinishedEvent("test2", 10));
|
||||
|
||||
//check that after finishing suite (suite3), current will be parent of finished suite (i.e. suite2)
|
||||
myEventsProcessor.onSuiteFinished("suite3");
|
||||
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite3"));
|
||||
onTestStarted("test3");
|
||||
final SMTestProxy test3 =
|
||||
myEventsProcessor.getProxyByFullTestName(myEventsProcessor.getFullTestName("test3"));
|
||||
assertEquals("suite2", test3.getParent().getName());
|
||||
|
||||
//clean up
|
||||
myEventsProcessor.onSuiteFinished("suite2");
|
||||
myEventsProcessor.onSuiteFinished("suite1");
|
||||
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite2"));
|
||||
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite1"));
|
||||
}
|
||||
|
||||
public void testOnSuiteStarted_WithLocation() {
|
||||
@@ -336,17 +337,17 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
}
|
||||
|
||||
public void testConcurrentSuite_intersected() {
|
||||
myEventsProcessor.onSuiteStarted("suite1", null);
|
||||
myEventsProcessor.onTestStarted("suite2.test1", null);
|
||||
myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent("suite1", null));
|
||||
myEventsProcessor.onTestStarted(new TestStartedEvent("suite2.test1", null));
|
||||
|
||||
final SMTestProxy test1 =
|
||||
myEventsProcessor.getProxyByFullTestName(myEventsProcessor.getFullTestName("suite2.test1"));
|
||||
|
||||
myEventsProcessor.onSuiteFinished("suite1");
|
||||
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite1"));
|
||||
|
||||
myEventsProcessor.onSuiteStarted("suite2", null);
|
||||
myEventsProcessor.onTestFinished("suite2.test1", 10);
|
||||
myEventsProcessor.onSuiteFinished("suite2");
|
||||
myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent("suite2", null));
|
||||
myEventsProcessor.onTestFinished(new TestFinishedEvent("suite2.test1", 10));
|
||||
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite2"));
|
||||
|
||||
assertEquals("suite1", test1.getParent().getName());
|
||||
|
||||
@@ -371,7 +372,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
}
|
||||
|
||||
private void onTestStarted(final String testName, @Nullable final String locationUrl) {
|
||||
myEventsProcessor.onTestStarted(testName, locationUrl);
|
||||
myEventsProcessor.onTestStarted(new TestStartedEvent(testName, locationUrl));
|
||||
myResultsViewer.performUpdate();
|
||||
}
|
||||
|
||||
@@ -380,7 +381,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
}
|
||||
|
||||
private void onTestSuiteStarted(final String suiteName, @Nullable final String locationUrl) {
|
||||
myEventsProcessor.onSuiteStarted(suiteName, locationUrl);
|
||||
myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent(suiteName, locationUrl));
|
||||
myResultsViewer.performUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
+27
-13
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package com.intellij.execution.testframework.sm.runner;
|
||||
|
||||
import com.intellij.execution.testframework.sm.runner.events.*;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.testIntegration.TestLocationProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -24,46 +26,46 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public class MockGeneralTestEventsProcessorAdapter implements GeneralTestEventsProcessor {
|
||||
private final StringBuilder myOutputBuffer = new StringBuilder();
|
||||
|
||||
@Override
|
||||
public void onStartTesting() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestsCountInSuite(int count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestStarted(@NotNull String testName, @Nullable String locationUrl) {
|
||||
public void onTestStarted(@NotNull TestStartedEvent testStartedEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestFinished(@NotNull String testName, int duration) {
|
||||
public void onTestFinished(@NotNull TestFinishedEvent testFinishedEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestFailure(@NotNull String testName,
|
||||
@NotNull String localizedMessage,
|
||||
@Nullable String stackTrace,
|
||||
boolean testError,
|
||||
@Nullable String comparisionFailureActualText,
|
||||
@Nullable String comparisionFailureExpectedText) {
|
||||
public void onTestFailure(@NotNull TestFailedEvent testFailedEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestIgnored(@NotNull String testName, @NotNull String ignoreComment, @Nullable String stackTrace) {
|
||||
public void onTestIgnored(@NotNull TestIgnoredEvent testIgnoredEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestOutput(@NotNull String testName, @NotNull String text, boolean stdOut) {
|
||||
public void onTestOutput(@NotNull TestOutputEvent testOutputEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuiteStarted(@NotNull String suiteName, @Nullable String locationUrl) {
|
||||
public void onSuiteStarted(@NotNull TestSuiteStartedEvent suiteStartedEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuiteFinished(@NotNull String suiteName) {
|
||||
public void onSuiteFinished(@NotNull TestSuiteFinishedEvent suiteFinishedEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUncapturedOutput(@NotNull String text, Key outputType) {
|
||||
myOutputBuffer.append("[").append(outputType.toString()).append("]"+ text);
|
||||
myOutputBuffer.append("[").append(outputType.toString()).append("]").append(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,6 +88,18 @@ public class MockGeneralTestEventsProcessorAdapter implements GeneralTestEventsP
|
||||
public void onTestsReporterAttached() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocator(@NotNull TestLocationProvider locator) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEventsListener(@NotNull SMTRunnerEventsListener viewer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinishTesting() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
myOutputBuffer.setLength(0);
|
||||
|
||||
+54
-53
@@ -22,6 +22,7 @@ import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.testframework.Printable;
|
||||
import com.intellij.execution.testframework.Printer;
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.execution.testframework.sm.runner.events.*;
|
||||
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.SMTestRunnerResultsForm;
|
||||
@@ -174,8 +175,8 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testProcessor_OnTestStdOutput() {
|
||||
startTestWithPrinter("my_test");
|
||||
|
||||
myEventsProcessor.onTestOutput("my_test", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test", "stdout2", true);
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout2", true));
|
||||
|
||||
assertStdOutput(myMockResetablePrinter, "stdout1 stdout2");
|
||||
}
|
||||
@@ -183,8 +184,8 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testProcessor_OnTestStdErr() {
|
||||
startTestWithPrinter("my_test");
|
||||
|
||||
myEventsProcessor.onTestOutput("my_test", "stderr1 ", false);
|
||||
myEventsProcessor.onTestOutput("my_test", "stderr2", false);
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr2", false));
|
||||
|
||||
assertStdErr(myMockResetablePrinter, "stderr1 stderr2");
|
||||
}
|
||||
@@ -192,10 +193,10 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testProcessor_OnTestMixedStd() {
|
||||
startTestWithPrinter("my_test");
|
||||
|
||||
myEventsProcessor.onTestOutput("my_test", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test", "stderr1 ", false);
|
||||
myEventsProcessor.onTestOutput("my_test", "stdout2", true);
|
||||
myEventsProcessor.onTestOutput("my_test", "stderr2", false);
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout2", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr2", false));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "stdout1 stdout2", "stderr1 stderr2", "");
|
||||
}
|
||||
@@ -203,9 +204,9 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testProcessor_OnFailure() {
|
||||
final SMTestProxy myTest1 = startTestWithPrinter("my_test");
|
||||
|
||||
myEventsProcessor.onTestFailure("my_test", "error msg", "method1:1\nmethod2:2", false, null, null);
|
||||
myEventsProcessor.onTestOutput("my_test", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test", "stderr1 ", false);
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("my_test", "error msg", "method1:1\nmethod2:2", false, null, null));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "stdout1 ", "\nerror msg\nmethod1:1\nmethod2:2\nstderr1 ", "");
|
||||
|
||||
@@ -215,9 +216,9 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
//other output order
|
||||
final SMTestProxy myTest2 = startTestWithPrinter("my_test2");
|
||||
myEventsProcessor.onTestOutput("my_test2", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test2", "stderr1 ", false);
|
||||
myEventsProcessor.onTestFailure("my_test2", "error msg", "method1:1\nmethod2:2", false, null, null);
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stderr1 ", false));
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("my_test2", "error msg", "method1:1\nmethod2:2", false, null, null));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "stdout1 ", "stderr1 \nerror msg\nmethod1:1\nmethod2:2\n", "");
|
||||
final MockPrinter mockPrinter2 = new MockPrinter(true);
|
||||
@@ -228,9 +229,9 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testProcessor_OnFailure_EmptyStacktrace() {
|
||||
final SMTestProxy myTest1 = startTestWithPrinter("my_test");
|
||||
|
||||
myEventsProcessor.onTestFailure("my_test", "error msg", "\n\n", false, null, null);
|
||||
myEventsProcessor.onTestOutput("my_test", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test", "stderr1 ", false);
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("my_test", "error msg", "\n\n", false, null, null));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "stdout1 ", "\nerror msg\nstderr1 ", "");
|
||||
|
||||
@@ -242,9 +243,9 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testProcessor_OnFailure_Comparision_Strings() {
|
||||
final SMTestProxy myTest1 = startTestWithPrinter("my_test");
|
||||
|
||||
myEventsProcessor.onTestFailure("my_test", "error msg", "method1:1\nmethod2:2", false, "actual", "expected");
|
||||
myEventsProcessor.onTestOutput("my_test", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test", "stderr1 ", false);
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("my_test", "error msg", "method1:1\nmethod2:2", false, "actual", "expected"));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter,
|
||||
// std out
|
||||
@@ -281,10 +282,10 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testProcessor_OnFailure_Comparision_MultilineTexts() {
|
||||
final SMTestProxy myTest1 = startTestWithPrinter("my_test");
|
||||
|
||||
myEventsProcessor.onTestFailure("my_test", "error msg", "method1:1\nmethod2:2", false,
|
||||
"this is:\nactual", "this is:\nexpected");
|
||||
myEventsProcessor.onTestOutput("my_test", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test", "stderr1 ", false);
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("my_test", "error msg", "method1:1\nmethod2:2", false,
|
||||
"this is:\nactual", "this is:\nexpected"));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "stdout1 ", "\nerror msg \n" +
|
||||
"\n" +
|
||||
@@ -304,9 +305,9 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testProcessor_OnError() {
|
||||
final SMTestProxy myTest1 = startTestWithPrinter("my_test");
|
||||
|
||||
myEventsProcessor.onTestFailure("my_test", "error msg", "method1:1\nmethod2:2", true, null, null);
|
||||
myEventsProcessor.onTestOutput("my_test", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test", "stderr1 ", false);
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("my_test", "error msg", "method1:1\nmethod2:2", true, null, null));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "stdout1 ", "\nerror msg\nmethod1:1\nmethod2:2\nstderr1 ", "");
|
||||
|
||||
@@ -316,9 +317,9 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
//other output order
|
||||
final SMTestProxy myTest2 = startTestWithPrinter("my_test2");
|
||||
myEventsProcessor.onTestOutput("my_test2", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test2", "stderr1 ", false);
|
||||
myEventsProcessor.onTestFailure("my_test2", "error msg", "method1:1\nmethod2:2", true, null, null);
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stderr1 ", false));
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("my_test2", "error msg", "method1:1\nmethod2:2", true, null, null));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "stdout1 ", "stderr1 \nerror msg\nmethod1:1\nmethod2:2\n", "");
|
||||
final MockPrinter mockPrinter2 = new MockPrinter(true);
|
||||
@@ -330,8 +331,8 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy myTest1 = startTestWithPrinter("my_test");
|
||||
|
||||
myEventsProcessor.onError("error msg", "method1:1\nmethod2:2", true);
|
||||
myEventsProcessor.onTestOutput("my_test", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test", "stderr1 ", false);
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "stdout1 ", "\nerror msg\nmethod1:1\nmethod2:2\nstderr1 ", "");
|
||||
|
||||
@@ -342,13 +343,13 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
"method1:1\n" +
|
||||
"method2:2\n" +
|
||||
"stderr1 ", "");
|
||||
myEventsProcessor.onTestFinished("my_test", 1);
|
||||
myEventsProcessor.onTestFinished(new TestFinishedEvent("my_test", 1));
|
||||
myTest1.setFinished();
|
||||
|
||||
//other output order
|
||||
final SMTestProxy myTest2 = startTestWithPrinter("my_test2");
|
||||
myEventsProcessor.onTestOutput("my_test2", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test2", "stderr1 ", false);
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stderr1 ", false));
|
||||
myEventsProcessor.onError("error msg", "method1:1\nmethod2:2", true);
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "stdout1 ", "stderr1 \nerror msg\nmethod1:1\nmethod2:2\n", "");
|
||||
@@ -360,7 +361,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testProcessor_Suite_OnErrorMsg() {
|
||||
myEventsProcessor.onError("error msg:root", "method1:1\nmethod2:2", true);
|
||||
|
||||
myEventsProcessor.onSuiteStarted("suite", null);
|
||||
myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent("suite", null));
|
||||
final SMTestProxy suite = myEventsProcessor.getCurrentSuite();
|
||||
suite.setPrinter(myMockResetablePrinter);
|
||||
myEventsProcessor.onError("error msg:suite", "method1:1\nmethod2:2", true);
|
||||
@@ -391,9 +392,9 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testProcessor_OnIgnored() {
|
||||
final SMTestProxy myTest1 = startTestWithPrinter("my_test");
|
||||
|
||||
myEventsProcessor.onTestIgnored("my_test", "ignored msg", null);
|
||||
myEventsProcessor.onTestOutput("my_test", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test", "stderr1 ", false);
|
||||
myEventsProcessor.onTestIgnored(new TestIgnoredEvent("my_test", "ignored msg", null));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "stdout1 ", "stderr1 ", "\nignored msg\n");
|
||||
|
||||
@@ -403,9 +404,9 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
//other output order
|
||||
final SMTestProxy myTest2 = startTestWithPrinter("my_test2");
|
||||
myEventsProcessor.onTestOutput("my_test2", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test2", "stderr1 ", false);
|
||||
myEventsProcessor.onTestIgnored("my_test2", "ignored msg", null);
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stderr1 ", false));
|
||||
myEventsProcessor.onTestIgnored(new TestIgnoredEvent("my_test2", "ignored msg", null));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "stdout1 ", "stderr1 ", "\nignored msg\n");
|
||||
final MockPrinter mockPrinter2 = new MockPrinter(true);
|
||||
@@ -416,9 +417,9 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testProcessor_OnIgnored_WithStacktrace() {
|
||||
final SMTestProxy myTest1 = startTestWithPrinter("my_test");
|
||||
|
||||
myEventsProcessor.onTestIgnored("my_test", "ignored2 msg", "method1:1\nmethod2:2");
|
||||
myEventsProcessor.onTestOutput("my_test", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test", "stderr1 ", false);
|
||||
myEventsProcessor.onTestIgnored(new TestIgnoredEvent("my_test", "ignored2 msg", "method1:1\nmethod2:2"));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "stdout1 ",
|
||||
"\nmethod1:1\nmethod2:2\nstderr1 ",
|
||||
@@ -433,9 +434,9 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
//other output order
|
||||
final SMTestProxy myTest2 = startTestWithPrinter("my_test2");
|
||||
myEventsProcessor.onTestOutput("my_test2", "stdout1 ", true);
|
||||
myEventsProcessor.onTestOutput("my_test2", "stderr1 ", false);
|
||||
myEventsProcessor.onTestIgnored("my_test2", "ignored msg", "method1:1\nmethod2:2");
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stdout1 ", true));
|
||||
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stderr1 ", false));
|
||||
myEventsProcessor.onTestIgnored(new TestIgnoredEvent("my_test2", "ignored msg", "method1:1\nmethod2:2"));
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter,
|
||||
"stdout1 ",
|
||||
@@ -465,7 +466,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testOnUncapturedOutput_SomeSuite() {
|
||||
myEventsProcessor.onStartTesting();
|
||||
|
||||
myEventsProcessor.onSuiteStarted("my suite", null);
|
||||
myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent("my suite", null));
|
||||
final SMTestProxy mySuite = myEventsProcessor.getCurrentSuite();
|
||||
assertTrue(mySuite != myRootSuite);
|
||||
mySuite.setPrinter(myMockResetablePrinter);
|
||||
@@ -476,7 +477,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testOnUncapturedOutput_SomeTest() {
|
||||
myEventsProcessor.onStartTesting();
|
||||
|
||||
myEventsProcessor.onSuiteStarted("my suite", null);
|
||||
myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent("my suite", null));
|
||||
startTestWithPrinter("my test");
|
||||
|
||||
assertOnUncapturedOutput();
|
||||
@@ -514,9 +515,9 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
myConsole.attachToProcess(null);
|
||||
|
||||
myEventsProcessor.onStartTesting();
|
||||
myEventsProcessor.onSuiteStarted("suite", null);
|
||||
myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent("suite", null));
|
||||
final SMTestProxy suite = myEventsProcessor.getCurrentSuite();
|
||||
myEventsProcessor.onSuiteFinished("suite");
|
||||
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite"));
|
||||
myEventsProcessor.onUncapturedOutput("preved", ProcessOutputTypes.STDOUT);
|
||||
myEventsProcessor.onFinishTesting();
|
||||
|
||||
@@ -536,7 +537,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
}
|
||||
|
||||
private SMTestProxy startTestWithPrinter(final String testName) {
|
||||
myEventsProcessor.onTestStarted(testName, null);
|
||||
myEventsProcessor.onTestStarted(new TestStartedEvent(testName, null));
|
||||
final SMTestProxy proxy =
|
||||
myEventsProcessor.getProxyByFullTestName(myEventsProcessor.getFullTestName(testName));
|
||||
proxy.setPrinter(myMockResetablePrinter);
|
||||
|
||||
+17
-16
@@ -21,6 +21,7 @@ import com.intellij.execution.testframework.sm.Marker;
|
||||
import com.intellij.execution.testframework.sm.runner.BaseSMTRunnerTestCase;
|
||||
import com.intellij.execution.testframework.sm.runner.GeneralToSMTRunnerEventsConvertor;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.execution.testframework.sm.runner.events.*;
|
||||
import com.intellij.openapi.progress.util.ColorProgressBar;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
@@ -226,24 +227,24 @@ public class SMTestRunnerResultsFormTest extends BaseSMTRunnerTestCase {
|
||||
TestConsoleProperties.HIDE_PASSED_TESTS.set(myConsoleProperties, true);
|
||||
|
||||
myEventsProcessor.onStartTesting();
|
||||
myEventsProcessor.onSuiteStarted("suite", null);
|
||||
myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent("suite", null));
|
||||
myResultsViewer.performUpdate();
|
||||
|
||||
myEventsProcessor.onTestStarted("test_failed", null);
|
||||
myEventsProcessor.onTestStarted(new TestStartedEvent("test_failed", null));
|
||||
myResultsViewer.performUpdate();
|
||||
myEventsProcessor.onTestFailure("test_failed", "", "", false, null, null);
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("test_failed", "", "", false, null, null));
|
||||
myResultsViewer.performUpdate();
|
||||
myEventsProcessor.onTestFinished("test_failed", 10);
|
||||
myEventsProcessor.onTestFinished(new TestFinishedEvent("test_failed", 10));
|
||||
myResultsViewer.performUpdate();
|
||||
|
||||
myEventsProcessor.onTestStarted("test", null);
|
||||
myEventsProcessor.onTestStarted(new TestStartedEvent("test", null));
|
||||
myResultsViewer.performUpdate();
|
||||
assertEquals(2, myTreeModel.getChildCount(myTreeModel.getChild(myTreeModel.getRoot(), 0)));
|
||||
|
||||
myEventsProcessor.onTestFinished("test", 10);
|
||||
myEventsProcessor.onTestFinished(new TestFinishedEvent("test", 10));
|
||||
assertEquals(2, myTreeModel.getChildCount(myTreeModel.getChild(myTreeModel.getRoot(), 0)));
|
||||
|
||||
myEventsProcessor.onSuiteFinished("suite");
|
||||
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite"));
|
||||
myEventsProcessor.onFinishTesting();
|
||||
|
||||
assertEquals(1, myTreeModel.getChildCount(myTreeModel.getChild(myTreeModel.getRoot(), 0)));
|
||||
@@ -251,27 +252,27 @@ public class SMTestRunnerResultsFormTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
public void testExpandIfOnlyOneRootChild() throws InterruptedException {
|
||||
myEventsProcessor.onStartTesting();
|
||||
myEventsProcessor.onSuiteStarted("suite1", null);
|
||||
myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent("suite1", null));
|
||||
myResultsViewer.performUpdate();
|
||||
myEventsProcessor.onSuiteStarted("suite2", null);
|
||||
myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent("suite2", null));
|
||||
myResultsViewer.performUpdate();
|
||||
|
||||
myEventsProcessor.onTestStarted("test_failed", null);
|
||||
myEventsProcessor.onTestStarted(new TestStartedEvent("test_failed", null));
|
||||
myResultsViewer.performUpdate();
|
||||
myEventsProcessor.onTestFailure("test_failed", "", "", false, null, null);
|
||||
myEventsProcessor.onTestFailure(new TestFailedEvent("test_failed", "", "", false, null, null));
|
||||
myResultsViewer.performUpdate();
|
||||
myEventsProcessor.onTestFinished("test_failed", 10);
|
||||
myEventsProcessor.onTestFinished(new TestFinishedEvent("test_failed", 10));
|
||||
myResultsViewer.performUpdate();
|
||||
|
||||
myEventsProcessor.onTestStarted("test", null);
|
||||
myEventsProcessor.onTestStarted(new TestStartedEvent("test", null));
|
||||
myResultsViewer.performUpdate();
|
||||
|
||||
myEventsProcessor.onTestFinished("test", 10);
|
||||
myEventsProcessor.onTestFinished(new TestFinishedEvent("test", 10));
|
||||
myResultsViewer.performUpdate();
|
||||
|
||||
myEventsProcessor.onSuiteFinished("suite2");
|
||||
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite2"));
|
||||
myResultsViewer.performUpdate();
|
||||
myEventsProcessor.onSuiteFinished("suite1");
|
||||
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite1"));
|
||||
myResultsViewer.performUpdate();
|
||||
myEventsProcessor.onFinishTesting();
|
||||
myResultsViewer.performUpdate();
|
||||
|
||||
Reference in New Issue
Block a user