If the same test class is run over and over, we assume the existing browser session will suffice to handle it. However, if the test fails to even get launched, we end up just sitting around waiting for nothing until timeouts occur for all the rest of the tests. This patch records whenever the last run failed to start, so that it won't even try to run subsequent tests. This particularly improves the failure mode when the test class module fails to compile. Also bumped the timeout to 30 seconds instead of 20.
Review by: tobyr
mmendez
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@724 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/junit/JUnitShell.java b/user/src/com/google/gwt/junit/JUnitShell.java
index f278af4..2303d5a 100644
--- a/user/src/com/google/gwt/junit/JUnitShell.java
+++ b/user/src/com/google/gwt/junit/JUnitShell.java
@@ -82,7 +82,7 @@
* Wait a long time for the client to contact the server and begin running the
* test.
*/
- private static final int TEST_BEGIN_TIMEOUT_MILLIS = 20000;
+ private static final int TEST_BEGIN_TIMEOUT_MILLIS = 30000;
/**
* Singleton object for hosting unit tests. All test case instances executed
@@ -145,6 +145,11 @@
private PrintWriterTreeLogger consoleLogger;
/**
+ * If true, the last attempt to launch failed.
+ */
+ private boolean lastLaunchFailed;
+
+ /**
* Portal to interact with the servlet.
*/
private JUnitMessageQueue messageQueue = new JUnitMessageQueue();
@@ -323,11 +328,21 @@
TestResult testResult) throws UnableToCompleteException {
String newTestCaseClassName = testCase.getClass().getName();
+ boolean sameTest = newTestCaseClassName.equals(testCaseClassName);
+ if (sameTest && lastLaunchFailed) {
+ throw new UnableToCompleteException();
+ }
+
messageQueue.setNextTestName(newTestCaseClassName, testCase.getName());
- boolean forceLaunch = !newTestCaseClassName.equals(testCaseClassName);
- testCaseClassName = newTestCaseClassName;
- runStyle.maybeLaunchModule(moduleName, forceLaunch);
+ try {
+ lastLaunchFailed = false;
+ testCaseClassName = newTestCaseClassName;
+ runStyle.maybeLaunchModule(moduleName, !sameTest);
+ } catch (UnableToCompleteException e) {
+ lastLaunchFailed = true;
+ throw e;
+ }
// Wait for test to complete
try {