My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for


This is not the latest version.
To see the latest version,
go to GWT Developer's Guide (latest)

DevGuideJUnitSuites  
Increase the speed of your unit test runs by organizing your tests into suites
Updated Feb 4, 2010 by zundel@google.com

Combining TestCase classes into a TestSuite

The GWTTestSuite mechanism has the overhead of having to start a hosted mode shell and servlet or compile your code. You can potentially increase the speed of your unit test runs by organizing your tests into suites of test cases.

Combining test cases together into a single GWTTestSuite reduces overhead if multiple GWTTestCase classes share the same module (that is, they return the same value from getModuleName().) The GWTTestSuite class re-orders the test cases so that all cases that share a module are run back to back.

Creating a suite is simple if you have already defined individual JUnit TestCases or GWTTestCases. Here is an example:

public class MapsTestSuite extends GWTTestSuite {
  public static Test suite() {
    TestSuite suite = new TestSuite("Test for a Maps Application");
    suite.addTestSuite(MapTest.class); 
    suite.addTestSuite(EventTest.class);
    suite.addTestSuite(CopyTest.class);
    return suite;
  }
}

The three test cases MapTest, EventTest, and CopyTest can now all run in the same instance of JUnitShell.

java  -Xmx256M -cp "./src:./test:./bin:./junit.jar:/gwt/gwt-user.jar:/gwt/gwt-dev-linux.jar:/gwt/gwt-maps.jar" junit.textui.TestRunner com.example.MapsTestSuite

Sign in to add a comment
Powered by Google Project Hosting