Java Reference
In-Depth Information
Listing 13.16
A GWT test suite
public class AllTests extends GWTTestSuite {
B
public static Test suite() {
TestSuite suite = new TestSuite(
" com.google.gwt.sample.stockwatcher.client.AllTests ");
// $JUnit-BEGIN$
suite.addTestSuite( StockPriceTest.class );
suite.addTestSuite( StockWatcherTest.class );
// $JUnit-END$
return suite;
}
C
}
We made the class extend GWTTestSuite b to make this suite a GWT test suite. We
also replaced the String in the TestSuite constructor with the class name of the gen-
erated class C . This allows us to double-click the class name in the JU nit view and
jump to an editor for that test suite. The rest is standard JU nit code; we call addTest-
Suite with a class object to add a test case to the suite.
13.8.7
Running a test suite
In addition to the requirements for running a GWT test case, you must configure a
GWT test suite with more memory than the default settings allocate. Configure the
Java VM running the tests with at least 256 megabytes of RAM . With the Sun JVM , use
the following option: -Xmx256M. You must also add to the classpath the source directo-
ries for application and test code.
To wrap up GWT testing, recall that GWT test cases verify the asynchronous aspects
of your application, not the user interface. To test the GUI , use functional tests with
Selenium or HtmlUnit.
Although we've finished our brief tour of GWT testing, it's worth noting that GWT
includes the Speed Tracer tool to help you identify and fix performance problems by
visualizing instrumentation data taken from the browser.
13.9
Summary
In this chapter, we built on what you learned in chapter 12 about testing the presenta-
tion layer of applications, specifically as it relates to Ajax applications.
We showed that Ajax applications use many technologies layered in broad tiers:
HTML and JavaScript are used on the client; HTTP , XML , and JSON provide communi-
cation and data services; and the server side is viewed as a black box implementing ser-
vices accessed over the internet with HTTP .
We divided our testing strategies along similar patterns. We used functional tests
for the whole application stack as it appears to a user by driving and testing the appli-
cation with HtmlUnit and Selenium. We isolated JavaScript into libraries and tested
those independently with RhinoUnit and JsUnit. We validated server-side XML and
JSON services using Apache Commons HttpClient, JSL int, and jslint4java.
 
 
 
 
Search WWH ::




Custom Search