Author: br...@google.com
Date: Tue Jun 23 18:52:00 2009
New Revision: 5619

Modified:
    trunk/user/src/com/google/gwt/junit/rebind/GWTRunnerGenerator.java
     
trunk/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java

Log:
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



Modified: trunk/user/src/com/google/gwt/junit/rebind/GWTRunnerGenerator.java
==============================================================================
--- trunk/user/src/com/google/gwt/junit/rebind/GWTRunnerGenerator.java   
(original)
+++ trunk/user/src/com/google/gwt/junit/rebind/GWTRunnerGenerator.java  Tue  
Jun 23 18:52:00 2009
@@ -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("}");

Modified:  
trunk/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
==============================================================================
---  
trunk/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
       
(original)
+++  
trunk/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
       
Tue Jun 23 18:52:00 2009
@@ -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);

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to