Author: br...@google.com
Date: Tue Jun 23 17:40:28 2009
New Revision: 5617

Modified:
    trunk/user/src/com/google/gwt/junit/client/GWTTestCase.java
    trunk/user/src/com/google/gwt/junit/tools/GWTTestSuite.java

Log:
Allows GWTTestCase#getModuleName() to return null to indicate it should be  
run as a normal JUnit tests case even though it extends GWTTestCase. See  
the issue for the rationale.

Patch by: bruce
Review by: scottb, amitmanjhi
Issue: 3772



Modified: trunk/user/src/com/google/gwt/junit/client/GWTTestCase.java
==============================================================================
--- trunk/user/src/com/google/gwt/junit/client/GWTTestCase.java (original)
+++ trunk/user/src/com/google/gwt/junit/client/GWTTestCase.java Tue Jun 23  
17:40:28 2009
@@ -118,7 +118,8 @@
     * return the name of a module that will cause the source for that  
subclass to
     * be included.
     *
-   * @return the fully qualified name of a module
+   * @return the fully qualified name of a module, or <code>null</code> to  
run
+   *         as a non-GWT test case
     */
    public abstract String getModuleName();

@@ -220,7 +221,14 @@
        throw new IllegalArgumentException("GWTTestCases require a name; \""  
+ this.toString()
            + "\" has none.  Perhaps you used TestSuite.addTest() instead of  
addTestClass()?");
      }
-    JUnitShell.runTest(getModuleName(), this, testResult);
+
+    String moduleName = getModuleName();
+    if (moduleName != null) {
+      JUnitShell.runTest(moduleName, this, testResult);
+    } else {
+      // Run as a non-GWT test
+      super.runTest();
+    }
    }

    /**

Modified: trunk/user/src/com/google/gwt/junit/tools/GWTTestSuite.java
==============================================================================
--- trunk/user/src/com/google/gwt/junit/tools/GWTTestSuite.java (original)
+++ trunk/user/src/com/google/gwt/junit/tools/GWTTestSuite.java Tue Jun 23  
17:40:28 2009
@@ -76,22 +76,29 @@
        } else {
          return getModuleSuiteFor(suite.testAt(0));
        }
-    } else if (test instanceof GWTTestCase) {
+    }
+
+    if (test instanceof GWTTestCase) {
        GWTTestCase gwtTest = (GWTTestCase) test;
-      TestSuite suite = moduleSuites.get(gwtTest.getModuleName());
-      if (suite == null) {
-        suite = new TestSuite(gwtTest.getModuleName() + ".gwt.xml");
-        moduleSuites.put(gwtTest.getModuleName(), suite);
-        super.addTest(suite);
-      }
-      return suite;
-    } else {
-      if (nonGWTTestSuite == null) {
-        nonGWTTestSuite = new TestSuite("Non-GWT");
-        super.addTest(nonGWTTestSuite);
+      String moduleName = gwtTest.getModuleName();
+      if (moduleName != null) {
+        TestSuite suite = moduleSuites.get(moduleName);
+        if (suite == null) {
+          suite = new TestSuite(moduleName + ".gwt.xml");
+          moduleSuites.put(moduleName, suite);
+          super.addTest(suite);
+        }
+        return suite;
+      } else {
+        // Fall-through to group with non-GWT tests.
        }
-      return nonGWTTestSuite;
      }
+
+    if (nonGWTTestSuite == null) {
+      nonGWTTestSuite = new TestSuite("Non-GWT");
+      super.addTest(nonGWTTestSuite);
+    }
+    return nonGWTTestSuite;
    }

    /**

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

Reply via email to