fixed [IDEADEV-41319] test runner: do not show green balloon and green progress bar if no tests were found

This commit is contained in:
Roman Chernyatchik
2009-11-13 16:41:01 +03:00
parent d942f2978d
commit 8fc03ec705
6 changed files with 158 additions and 1 deletions
@@ -211,6 +211,10 @@ public class ColorProgressBar extends JComponent {
return dimension;
}
public Color getColor() {
return myColor;
}
@SuppressWarnings({"HardCodedStringLiteral"})
public static void main(String[] args) {
JFrame frame = new JFrame("ColorProgressBar Test");
@@ -16,6 +16,7 @@
package com.intellij.execution.testframework.sm.runner.ui;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.execution.testframework.sm.SMTestsRunnerBundle;
import com.intellij.execution.testframework.sm.runner.SMTRunnerEventsAdapter;
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
import com.intellij.execution.testframework.sm.runner.states.TestStateInfo;
@@ -66,6 +67,12 @@ public class SMTRunnerNotificationsHandler extends SMTRunnerEventsAdapter {
type = MessageType.ERROR;
break;
case COMPLETE_INDEX:
if (testsRoot.getChildren().size() == 0) {
msg = SMTestsRunnerBundle.message("sm.test.runner.ui.tests.tree.presentation.labels.no.tests.were.found");
type = MessageType.ERROR;
break;
}
// else same as: PASSED_INDEX
case PASSED_INDEX:
msg = "Tests passed";
type = MessageType.INFO;
@@ -216,6 +216,10 @@ public class SMTestRunnerResultsForm extends TestResultsPanel implements TestFra
}
updateStatusLabel();
if (myTestsRootNode.getChildren().size() == 0) {
// no tests found
myStatusLine.setStatusColor(ColorProgressBar.RED);
}
myAnimator.stopMovie();
myTreeBuilder.updateFromRoot();
@@ -374,6 +378,10 @@ public class SMTestRunnerResultsForm extends TestResultsPanel implements TestFra
return myTestsFailuresCount;
}
protected Color getTestsStatusColor() {
return myStatusLine.getStatusColor();
}
protected int getTestsTotal() {
return myTestsTotal;
}
@@ -171,6 +171,120 @@ public class SMTRunnerUIActionsHandlerTest extends BaseSMTRunnerTestCase {
}
public void testSelectFirstDeffect_Priority_Error() {
// Priority: error -> failure -> pending
TestConsoleProperties.SELECT_FIRST_DEFECT.set(myProperties, true);
mySuite.setStarted();
final SMTestProxy testsSuite = createSuiteProxy("my suite", mySuite);
testsSuite.setStarted();
// pending test
final SMTestProxy testPending = createTestProxy("testPending", testsSuite);
testPending.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testPending);
testPending.setTestIgnored("", "");
//failed test
final SMTestProxy testFailed = createTestProxy("testFailed", testsSuite);
testFailed.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testFailed);
testFailed.setTestFailed("", "", false);
//error test
final SMTestProxy testError = createTestProxy("testError", testsSuite);
testError.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testError);
testError.setTestFailed("", "", true);
// Second error test just to check that first failed will be selected
final SMTestProxy testError2 = createTestProxy("testError2", testsSuite);
testError2.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testError2);
testError2.setTestFailed("", "", true);
// finish suite
testsSuite.setFinished();
assertNull(mySelectedTestProxy);
//testing finished
mySuite.setFinished();
assertNull(mySelectedTestProxy);
myUIActionsHandler.onTestingFinished(myResultsViewer);
assertEquals(testError, mySelectedTestProxy);
}
public void testSelectFirstDeffect_Priority_Failure() {
// Priority: error -> failure -> pending
TestConsoleProperties.SELECT_FIRST_DEFECT.set(myProperties, true);
mySuite.setStarted();
final SMTestProxy testsSuite = createSuiteProxy("my suite", mySuite);
testsSuite.setStarted();
// pending test
final SMTestProxy testPending = createTestProxy("testPending", testsSuite);
testPending.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testPending);
testPending.setTestIgnored("", "");
//failed test
final SMTestProxy testFailed = createTestProxy("testFailed", testsSuite);
testFailed.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testFailed);
testFailed.setTestFailed("", "", false);
// Second failed test just to check that first failed will be selected
final SMTestProxy testFailed2 = createTestProxy("testFailed2", testsSuite);
testFailed2.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testFailed2);
testFailed2.setTestFailed("", "", false);
// finish suite
testsSuite.setFinished();
assertNull(mySelectedTestProxy);
//testing finished
mySuite.setFinished();
assertNull(mySelectedTestProxy);
myUIActionsHandler.onTestingFinished(myResultsViewer);
assertEquals(testFailed, mySelectedTestProxy);
}
public void testSelectFirstDeffect_Priority_Pending() {
// Priority: error -> failure -> pending
TestConsoleProperties.SELECT_FIRST_DEFECT.set(myProperties, true);
mySuite.setStarted();
final SMTestProxy testsSuite = createSuiteProxy("my suite", mySuite);
testsSuite.setStarted();
// pending test
final SMTestProxy testPending = createTestProxy("testPending", testsSuite);
testPending.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testPending);
testPending.setTestIgnored("", "");
// Second pending test just to check that first failed will be selected
final SMTestProxy testPending2 = createTestProxy("testPending2", testsSuite);
testPending2.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testPending2);
testPending2.setTestIgnored("", "");
// finish suite
testsSuite.setFinished();
assertNull(mySelectedTestProxy);
//testing finished
mySuite.setFinished();
assertNull(mySelectedTestProxy);
myUIActionsHandler.onTestingFinished(myResultsViewer);
assertEquals(testPending, mySelectedTestProxy);
}
public void testTrackRunningTest() {
TestConsoleProperties.TRACK_RUNNING_TEST.set(myProperties, true);
mySuite.setStarted();
@@ -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.openapi.progress.util.ColorProgressBar;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Ref;
import org.jetbrains.annotations.NotNull;
@@ -338,6 +339,26 @@ public class SMTestRunnerResultsFormTest extends BaseSMTRunnerTestCase {
myResultsViewer.onCustomProgressTestFailed();
assertEquals(1, myResultsViewer.getTestsFailuresCount());
assertEquals(ColorProgressBar.RED, myResultsViewer.getTestsStatusColor());
}
public void testCustomProgress_Terminated() {
myResultsViewer.onTestingStarted(myTestsRootNode);
final SMTestProxy test1 = createTestProxy("some_test1", myTestsRootNode);
myResultsViewer.onTestStarted(test1);
myResultsViewer.onTestingFinished(myTestsRootNode);
assertEquals(ColorProgressBar.GREEN, myResultsViewer.getTestsStatusColor());
}
public void testCustomProgress_NotRun() {
myResultsViewer.onTestingStarted(myTestsRootNode);
myResultsViewer.onTestingFinished(myTestsRootNode);
assertEquals(ColorProgressBar.RED, myResultsViewer.getTestsStatusColor());
}
public void testCustomProgress_UnSetCount() {
@@ -482,5 +503,4 @@ public class SMTestRunnerResultsFormTest extends BaseSMTRunnerTestCase {
myResultsViewer.onTestStarted(createTestProxy("some_test1", myTestsRootNode));
assertEquals(4, myResultsViewer.getTestsCurrentCount());
}
}
@@ -41,6 +41,10 @@ public class TestStatusLine extends JPanel {
myProgressBar.setColor(color);
}
public Color getStatusColor() {
return myProgressBar.getColor();
}
public void setFraction(double v) {
myProgressBar.setFraction(v);
}