diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java
index 89d7ba5d864a..fa79eea38f0d 100644
--- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java
+++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,12 +33,11 @@ import javax.swing.*;
import java.util.List;
/**
+ * Processes events of test runner in general text-based form.
+ *
+ * Test name should be unique for all suites - e.g. it can consist of a suite name and a name of a test method.
+ *
* @author: Roman Chernyatchik
- *
- * Processes events of test runner in general text-based form
- *
- * NB: Test name should be unique for all suites. E.g. it can consist of suite name
- * and name of test method
*/
public abstract class GeneralTestEventsProcessor implements Disposable {
private TransferToEDTQueue myTransferToEDTQueue =
@@ -68,35 +67,33 @@ public abstract class GeneralTestEventsProcessor implements Disposable {
public abstract void onSuiteFinished(@NotNull TestSuiteFinishedEvent suiteFinishedEvent);
- public abstract void onUncapturedOutput(@NotNull final String text,
- final Key outputType);
+ public abstract void onUncapturedOutput(@NotNull String text, Key outputType);
- public abstract void onError(@NotNull final String localizedMessage,
- @Nullable final String stackTrace,
- final boolean isCritical);
+ public abstract void onError(@NotNull String localizedMessage, @Nullable String stackTrace, boolean isCritical);
+
+ public abstract void onFinishTesting();
// Custom progress statistics
/**
* @param categoryName If isn't empty then progress statistics will use only custom start/failed events.
* If name is null statistics will be switched to normal mode
- * @param testCount - 0 will be considered as unknown tests number
+ * @param testCount 0 will be considered as unknown tests number
*/
- public abstract void onCustomProgressTestsCategory(@Nullable final String categoryName,
- final int testCount);
+ public abstract void onCustomProgressTestsCategory(@Nullable String categoryName, int testCount);
public abstract void onCustomProgressTestStarted();
public abstract void onCustomProgressTestFailed();
+ // workflow/service methods
+
public abstract void onTestsReporterAttached();
public abstract void setLocator(@NotNull TestLocationProvider locator);
public abstract void addEventsListener(@NotNull SMTRunnerEventsListener viewer);
- public abstract void onFinishTesting();
-
public abstract void setPrinterProvider(@NotNull TestProxyPrinterProvider printerProvider);
@Override
@@ -115,18 +112,12 @@ public abstract class GeneralTestEventsProcessor implements Disposable {
return Conditions.alwaysFalse();
}
- /**
- * Adds runnable to Event Dispatch Queue
- * if we aren't in UnitTest of Headless environment mode
- *
- * @param runnable Runnable
- */
public void addToInvokeLater(final Runnable runnable) {
final Application application = ApplicationManager.getApplication();
- final boolean unitTestMode = application.isUnitTestMode();
- if (unitTestMode) {
+ if (application.isUnitTestMode()) {
UIUtil.invokeLaterIfNeeded(runnable);
- } else if (application.isHeadlessEnvironment() || SwingUtilities.isEventDispatchThread()) {
+ }
+ else if (application.isHeadlessEnvironment() || SwingUtilities.isEventDispatchThread()) {
runnable.run();
}
else {
diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java
index 94414950362a..cf6d619cf5fd 100644
--- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java
+++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,28 +32,26 @@ import java.util.Map;
import static com.intellij.execution.testframework.sm.runner.GeneralToSMTRunnerEventsConvertor.getTFrameworkPrefix;
/**
+ * This implementation also supports messages split in parts by early flush.
+ * Implementation assumes that buffer is being flushed on line end or by timer,
+ * i.e. incoming text contains no more than one line's end marker ('\r', '\n', or "\r\n")
+ * (e.g. process was run with IDEA program's runner)
+ *
* @author Roman Chernyatchik
- *
- * This implementation also supports messages splitted in parts by early flush.
- * Implementation assumes that buffer is being flushed on line end or by timer,
- * i.e. incomming text contains no more than one line's end marker ('\r', '\n', or "\r\n")
- * (e.g. process was run with IDEA program's runner)
*/
public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer {
private static final Logger LOG = Logger.getInstance(OutputToGeneralTestEventsConverter.class.getName());
- private GeneralTestEventsProcessor myProcessor;
private final MyServiceMessageVisitor myServiceMessageVisitor;
private final String myTestFrameworkName;
-
private final OutputLineSplitter mySplitter;
+
+ private GeneralTestEventsProcessor myProcessor;
private boolean myPendingLineBreakFlag;
- public OutputToGeneralTestEventsConverter(@NotNull final String testFrameworkName,
- @NotNull final TestConsoleProperties consoleProperties) {
+ public OutputToGeneralTestEventsConverter(@NotNull String testFrameworkName, @NotNull TestConsoleProperties consoleProperties) {
myTestFrameworkName = testFrameworkName;
myServiceMessageVisitor = new MyServiceMessageVisitor();
-
mySplitter = new OutputLineSplitter(consoleProperties.isEditable()) {
@Override
protected void onLineAvailable(@NotNull String text, @NotNull Key outputType, boolean tcLikeFakeOutput) {
diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java
index 0f16bdde26be..1c9a352aed06 100644
--- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java
+++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java
@@ -52,9 +52,7 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements
* @param testFrameworkName Prefix for storage which keeps runner settings. E.g. "RubyTestUnit"
* @param executor
*/
- public SMTRunnerConsoleProperties(@NotNull RunConfiguration config,
- @NotNull String testFrameworkName,
- @NotNull Executor executor) {
+ public SMTRunnerConsoleProperties(@NotNull RunConfiguration config, @NotNull String testFrameworkName, @NotNull Executor executor) {
this(config, testFrameworkName, executor, true);
}
@@ -139,9 +137,7 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements
}
@Nullable
- protected Navigatable findSuitableNavigatableForLine(@NotNull final Project project,
- @NotNull final VirtualFile file,
- final int line) {
+ protected Navigatable findSuitableNavigatableForLine(@NotNull Project project, @NotNull VirtualFile file, int line) {
// lets find first non-ws psi element
final Document doc = FileDocumentManager.getInstance().getDocument(file);
diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java
index 7c844c76e058..219473b28fa2 100644
--- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java
+++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -51,36 +50,34 @@ import java.util.List;
public class SMTestProxy extends AbstractTestProxy {
private static final Logger LOG = Logger.getInstance(SMTestProxy.class.getName());
+ private final String myName;
+ private final boolean myIsSuite;
+ private final String myLocationUrl;
+ private final boolean myPreservePresentableName;
+
private List myChildren;
private SMTestProxy myParent;
private AbstractState myState = NotRunState.getInstance();
- private final String myName;
private Long myDuration = null; // duration is unknown
- @Nullable private final String myLocationUrl;
private boolean myDurationIsCached = false; // is used for separating unknown and unset duration
private boolean myHasCriticalErrors = false;
private boolean myHasErrorsCached = false;
private boolean myHasPassedTests = false;
private boolean myHasPassedTestsCached = false;
- @Nullable private String myStacktrace;
+ private String myStacktrace;
- private final boolean myIsSuite;
private boolean myIsEmptyIsCached = false; // is used for separating unknown and unset values
private boolean myIsEmpty = true;
- TestLocationProvider myLocator = null;
- private final boolean myPreservePresentableName;
+ private TestLocationProvider myLocator = null;
private Printer myPreferredPrinter = null;
- public SMTestProxy(final String testName, final boolean isSuite,
- @Nullable final String locationUrl) {
+ public SMTestProxy(String testName, boolean isSuite, @Nullable String locationUrl) {
this(testName, isSuite, locationUrl, false);
}
- public SMTestProxy(final String testName, final boolean isSuite,
- @Nullable final String locationUrl,
- boolean preservePresentableName) {
+ public SMTestProxy(String testName, boolean isSuite, @Nullable String locationUrl, boolean preservePresentableName) {
myName = testName;
myIsSuite = isSuite;
myLocationUrl = locationUrl;
@@ -96,8 +93,6 @@ public class SMTestProxy extends AbstractTestProxy {
}
public boolean isInProgress() {
- //final SMTestProxy parent = getParent();
-
return myState.isInProgress();
}
@@ -194,22 +189,21 @@ public class SMTestProxy extends AbstractTestProxy {
return false;
}
- @Override
+ @Override
public boolean isIgnored() {
- if (hasPassedTests()) {
- return false;
- }
- return myState.getMagnitude() == TestStateInfo.Magnitude.IGNORED_INDEX;
+ return !hasPassedTests() &&
+ myState.getMagnitude() == TestStateInfo.Magnitude.IGNORED_INDEX;
}
public boolean isPassed() {
return myState.getMagnitude() == TestStateInfo.Magnitude.SKIPPED_INDEX ||
myState.getMagnitude() == TestStateInfo.Magnitude.COMPLETE_INDEX ||
- myState.getMagnitude() == TestStateInfo.Magnitude.PASSED_INDEX;
+ myState.getMagnitude() == TestStateInfo.Magnitude.PASSED_INDEX;
}
public void addChild(@NotNull SMTestProxy child) {
ApplicationManager.getApplication().assertIsDispatchThread();
+
if (myChildren == null) {
myChildren = ContainerUtil.newArrayListWithCapacity(4);
}
@@ -246,7 +240,6 @@ public class SMTestProxy extends AbstractTestProxy {
super.setPrinter(getRightPrinter(printer));
}
-
public String getName() {
return myName;
}
@@ -255,8 +248,6 @@ public class SMTestProxy extends AbstractTestProxy {
public Location getLocation(final Project project, GlobalSearchScope searchScope) {
//determines location of test proxy
- //TODO multiresolve support
-
if (myLocationUrl == null || myLocator == null) {
return null;
}
@@ -300,7 +291,6 @@ public class SMTestProxy extends AbstractTestProxy {
}
public List extends SMTestProxy> getChildren() {
- //ApplicationManager.getApplication().assertIsDispatchThread();
return myChildren != null ? myChildren : Collections.emptyList();
}
@@ -316,13 +306,13 @@ public class SMTestProxy extends AbstractTestProxy {
return allTests;
}
-
public void setStarted() {
myState = !myIsSuite ? TestInProgressState.TEST : new SuiteInProgressState(this);
}
/**
* Calculates and caches duration of test or suite
+ *
* @return null if duration is unknown, otherwise duration value in milliseconds;
*/
@Nullable
@@ -352,6 +342,7 @@ public class SMTestProxy extends AbstractTestProxy {
/**
* Sets duration of test
+ *
* @param duration In milliseconds
*/
public void setDuration(final long duration) {
@@ -379,7 +370,8 @@ public class SMTestProxy extends AbstractTestProxy {
if (!isSuite()) {
// if isn't in other finished state (ignored, failed or passed)
myState = TestPassedState.INSTANCE;
- } else {
+ }
+ else {
//Test Suite
myState = determineSuiteStateOnFinished();
}
@@ -387,17 +379,13 @@ public class SMTestProxy extends AbstractTestProxy {
fireOnNewPrintable(myState);
}
- public void setTestFailed(@NotNull final String localizedMessage,
- @Nullable final String stackTrace,
- final boolean testError) {
+ public void setTestFailed(@NotNull String localizedMessage, @Nullable String stackTrace, boolean testError) {
setStacktraceIfNotSet(stackTrace);
if (myState instanceof TestFailedState) {
- ((TestFailedState) myState).addError(localizedMessage, stackTrace, myPrinter);
+ ((TestFailedState)myState).addError(localizedMessage, stackTrace, myPrinter);
}
else {
- myState = testError
- ? new TestErrorState(localizedMessage, stackTrace)
- : new TestFailedState(localizedMessage, stackTrace);
+ myState = testError ? new TestErrorState(localizedMessage, stackTrace) : new TestFailedState(localizedMessage, stackTrace);
fireOnNewPrintable(myState);
}
}
@@ -415,8 +403,7 @@ public class SMTestProxy extends AbstractTestProxy {
@NotNull final String expectedText,
@Nullable final String filePath) {
setStacktraceIfNotSet(stackTrace);
- myState = new TestComparisionFailedState(localizedMessage, stackTrace,
- actualText, expectedText, filePath);
+ myState = new TestComparisionFailedState(localizedMessage, stackTrace, actualText, expectedText, filePath);
fireOnNewPrintable(myState);
}
@@ -441,17 +428,15 @@ public class SMTestProxy extends AbstractTestProxy {
result.addAll(allChildren);
- for (SMTestProxy p: allChildren) {
+ for (SMTestProxy p : allChildren) {
result.addAll(p.collectChildren());
}
return result;
}
- public List extends SMTestProxy> getChildren(@Nullable final Filter super SMTestProxy> filter) {
- final List extends SMTestProxy> allChildren = getChildren();
-
- return filterChildren(filter, allChildren);
+ public List extends SMTestProxy> getChildren(@Nullable Filter super SMTestProxy> filter) {
+ return filterChildren(filter, getChildren());
}
private static List extends SMTestProxy> filterChildren(@Nullable Filter super SMTestProxy> filter,
@@ -470,6 +455,7 @@ public class SMTestProxy extends AbstractTestProxy {
if ((selectedChildren.isEmpty())) {
return Collections.emptyList();
}
+
return selectedChildren;
}
@@ -477,9 +463,9 @@ public class SMTestProxy extends AbstractTestProxy {
return myState.wasLaunched();
}
-
/**
* Prints this proxy and all its children on given printer
+ *
* @param printer Printer
*/
public void printOn(final Printer printer) {
@@ -520,23 +506,19 @@ public class SMTestProxy extends AbstractTestProxy {
* @deprecated use SMTestProxy.addError(String output, String stackTrace, boolean isCritical)
*/
@Deprecated
- public void addError(final String output,
- @Nullable final String stackTrace) {
+ public void addError(String output, @Nullable String stackTrace) {
addError(output, stackTrace, true);
}
- public void addError(final String output,
- @Nullable final String stackTrace,
- final boolean isCritical) {
+ public void addError(final String output, @Nullable final String stackTrace, boolean isCritical) {
myHasCriticalErrors = isCritical;
setStacktraceIfNotSet(stackTrace);
addLast(new Printable() {
public void printOn(final Printer printer) {
- final String errorText = TestFailedState.buildErrorPresentationText(output, stackTrace);
+ String errorText = TestFailedState.buildErrorPresentationText(output, stackTrace);
LOG.assertTrue(errorText != null);
-
- TestFailedState.printError(printer, Arrays.asList(errorText));
+ TestFailedState.printError(printer, Collections.singletonList(errorText));
}
});
}
@@ -607,6 +589,7 @@ public class SMTestProxy extends AbstractTestProxy {
/**
* Check if suite contains error tests or suites
+ *
* @return True if contains
*/
private boolean containsErrorTests() {
@@ -631,27 +614,32 @@ public class SMTestProxy extends AbstractTestProxy {
/**
* Determines site state after it has been finished
+ *
* @return New state
*/
protected AbstractState determineSuiteStateOnFinished() {
final AbstractState state;
if (isLeaf()) {
state = SuiteFinishedState.EMPTY_LEAF_SUITE;
- } else if (isEmptySuite()) {
+ }
+ else if (isEmptySuite()) {
state = SuiteFinishedState.EMPTY_SUITE;
- } else {
+ }
+ else {
if (isDefect()) {
// Test suit contains errors if at least one of its tests contains error
if (containsErrorTests()) {
state = SuiteFinishedState.ERROR_SUITE;
- } else {
+ }
+ else {
// if suite contains failed tests - all suite should be
// consider as failed
state = containsFailedTests()
- ? SuiteFinishedState.FAILED_SUITE
- : SuiteFinishedState.WITH_IGNORED_TESTS_SUITE;
+ ? SuiteFinishedState.FAILED_SUITE
+ : SuiteFinishedState.WITH_IGNORED_TESTS_SUITE;
}
- } else {
+ }
+ else {
state = SuiteFinishedState.PASSED_SUITE;
}
}
@@ -685,7 +673,8 @@ public class SMTestProxy extends AbstractTestProxy {
myIsEmpty = true;
// we can cache only final state, otherwise test may be added
myIsEmptyIsCached = myState.isFinal();
- } else {
+ }
+ else {
// test => parent suite isn't empty
myIsEmpty = false;
myIsEmptyIsCached = true;
@@ -696,7 +685,6 @@ public class SMTestProxy extends AbstractTestProxy {
}
-
@Nullable
private Long calcSuiteDuration() {
long partialDuration = 0;
diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtilTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtilTest.java
index a263bb186ef9..152a6288f298 100644
--- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtilTest.java
+++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtilTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -97,11 +97,11 @@ public class TestsPresentationUtilTest extends BaseSMTRunnerTestCase {
category.clear();
category.add("Cucumbers");
- category.add("Tomatos");
+ category.add("Tomatoes");
category.add(TestsPresentationUtil.DEFAULT_TESTS_CATEGORY);
- assertEquals("Running: Cucumbers, tomatos, tests 0 of <...> ",
+ assertEquals("Running: Cucumbers, tomatoes, tests 0 of <...> ",
TestsPresentationUtil.getProgressStatus_Text(0, 0, 0, 0, 0, category, false));
- assertEquals("Running: Cucumbers, tomatos, tests 0 of 0 ",
+ assertEquals("Running: Cucumbers, tomatoes, tests 0 of 0 ",
TestsPresentationUtil.getProgressStatus_Text(0, 0, 0, 0, 0, category, true));
category.clear();
@@ -285,7 +285,7 @@ public class TestsPresentationUtilTest extends BaseSMTRunnerTestCase {
public void testFormatTestProxyTest_WithErrors_LegacyApi() {
mySimpleTest.setStarted();
- mySimpleTest.addError("msg", "stacktrace");
+ mySimpleTest.addError("msg", "stacktrace", true);
mySimpleTest.setFinished();
TestsPresentationUtil.formatTestProxy(mySimpleTest, myRenderer);
@@ -298,7 +298,7 @@ public class TestsPresentationUtilTest extends BaseSMTRunnerTestCase {
mySimpleTest.setFinished();
TestsPresentationUtil.formatTestProxy(mySimpleTest, myRenderer);
- assertEquals(SMPoolOfTestIcons.PASSED_ICON, myRenderer.getIcon());
+ assertEquals(PoolOfTestIcons.PASSED_ICON, myRenderer.getIcon());
}
public void testFormatRootNodeWithChildren_Started() {
@@ -531,7 +531,7 @@ public class TestsPresentationUtilTest extends BaseSMTRunnerTestCase {
final MyRenderer renderer2 = new MyRenderer(false, myFragContainer = new UITestUtil.FragmentsContainer());
TestsPresentationUtil.formatTestProxy(mySimpleTest, renderer2);
- assertEquals(SMPoolOfTestIcons.PASSED_ICON, renderer2.getIcon());
+ assertEquals(PoolOfTestIcons.PASSED_ICON, renderer2.getIcon());
}
public void testFormatRootNodeWithoutChildren() {
@@ -713,7 +713,7 @@ public class TestsPresentationUtilTest extends BaseSMTRunnerTestCase {
return createTestProxy(FAKE_TEST_NAME);
}
- private void assertIsAnimatorProgressIcon(final Icon icon) {
+ private static void assertIsAnimatorProgressIcon(final Icon icon) {
for (Icon frame : TestsProgressAnimator.FRAMES) {
if (icon == frame) {
return;