Retains exception cause chain when GWTRunner fails to instantiate a test class (e.g. due to an exception in the test's ctor or initializer). Previously, it was really hard to figure out what was going wrong in web mode in this circumstance.
Suggested by: me
Patch by: scottb
Review by: me
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5619 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/junit/rebind/GWTRunnerGenerator.java b/user/src/com/google/gwt/junit/rebind/GWTRunnerGenerator.java
index 213e514..9e34312 100644
--- a/user/src/com/google/gwt/junit/rebind/GWTRunnerGenerator.java
+++ b/user/src/com/google/gwt/junit/rebind/GWTRunnerGenerator.java
@@ -169,8 +169,6 @@
sw.println();
sw.println("protected final GWTTestCase createNewTestCase(String testClass) {");
sw.indent();
- sw.println("try {");
- sw.indent();
boolean isFirst = true;
for (String className : testClasses) {
if (isFirst) {
@@ -183,11 +181,6 @@
sw.indentln("return GWT.create(" + className + ".class);");
sw.println("}");
}
- sw.outdent();
- sw.println("} catch (Throwable t) {");
- sw.indentln("// Crash in a useful manner");
- sw.indentln("GWT.log(\"Unable to construct TestCase: \" + testClass, t);");
- sw.println("}");
sw.println("return null;");
sw.outdent();
sw.println("}");
diff --git a/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java b/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
index ae70235..2a679a9 100644
--- a/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
+++ b/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
@@ -176,10 +176,16 @@
private void runTest() {
// Dynamically create a new test case.
- GWTTestCase testCase = createNewTestCase(currentTest.getTestClass());
+ GWTTestCase testCase = null;
+ Throwable caught = null;
+ try {
+ testCase = createNewTestCase(currentTest.getTestClass());
+ } catch (Throwable e) {
+ caught = e;
+ }
if (testCase == null) {
RuntimeException ex = new RuntimeException(currentTest
- + ": could not instantiate the requested class");
+ + ": could not instantiate the requested class", caught);
JUnitResult result = new JUnitResult();
result.setExceptionWrapper(new ExceptionWrapper(ex));
reportResultsAndGetNextMethod(result);