GWTTestCase
derived class launches an invisible browser that
your test runs inside of.
You can run your test in either hosted mode
or web mode. In hosted mode (the default),
your test cases run as bytecode in a JVM. To test in web mode as compiled
JavaScript, define the system property gwt.hybrid
by passing
in "-Dgwt.hybrid
" as a JVM argument.
GWT includes a handy junitCreator tool that will generate a starter test case for you, plus scripts for testing in both hosted mode and web mode. But here are the steps if you want to set it up by hand:
com.google.gwt.junit.JUnit
and whose test
subdirectory contains your class.src
directorybin
directorygwt-user.jar
gwt-dev-windows.jar
(or gwt-dev-linux.jar
)junit.jar
FooTest
.
public class FooTest extends GWTTestCase { /* * Specifies which module to use when running this test case. Must refer * to a valid module file that inherits com.google.gwt.junit.JUnit. * * @see com.google.gwt.junit.client.GWTTestCase#getModuleName() */ public String getModuleName() { return "com.example.foo.FooTest"; } public void testStuff() { assertTrue(2 + 2 == 4); } }Create a
com.example.foo.FooTest
module.
<module> <!-- Inherit the JUnit support --> <inherits name='com.google.gwt.junit.JUnit'/> <!-- Include client-side source we might like to test --> <source path="client"/> <!-- Include client-side source for the test cases --> <source path="test"/> </module>The module doesn't declare an entry points; the JUnit module handles that.
final
and cannot be overidden.com.example.foo.test
(or any subpackage) can share the com.example.foo.FooTest
module.