java.lang.Object | ||
↳ | TestCase | |
↳ | com.google.gwt.junit.client.GWTTestCase |
Known Direct Subclasses |
Acts as a bridge between the JUnit environment and the GWT environment. We hook the run method and stash the TestResult object for later communication between the test runner and the unit test shell that drives the test case inside a hosted browser.
There are two versions of this class. This version is the binary version that
derives from JUnit's TestCase and handles all the work of starting up
the GWT environment. The other version is a translatable class that is used
within the browser. See the translatable
subpackage for the
translatable implementation.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
GWTTestCase.BaseStrategy | The base class for strategies to use for tests. | ||||||||||
GWTTestCase.TestModuleInfo | Information about a synthetic module used for testing. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ALL_GWT_TESTS | Records all live GWTTestCases by synthetic module name so we can optimize run they are compiled and run. | ||||||||||
testResult | Object that collects the results of this test case execution. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
A new instance of your subclass is constructed for each test method that is
to be run.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This method is deprecated.
implementation removed
| |||||||||||
Determines whether or not exceptions will be caught by the test fixture.
| |||||||||||
This method is deprecated.
implementation removed
| |||||||||||
Get the names of all test modules.
| |||||||||||
This method is deprecated.
implementation removed
| |||||||||||
Get the number of modules.
| |||||||||||
Specifies a module to use when running this test case.
| |||||||||||
Get the
GWTTestCase.BaseStrategy to use when compiling and running this test. | |||||||||||
Get the synthetic module name, which includes the synthetic extension
defined by the
GWTTestCase.BaseStrategy . | |||||||||||
Get the set of all
JUnitHost.TestInfo for the specified module. | |||||||||||
Returns whether this test case should be run in pure Java mode (non-GWT).
| |||||||||||
Stashes
result so that it can be accessed during
runTest() . | |||||||||||
Specifies whether this test case should be always run in pure Java mode
(non-GWT).
| |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates the test strategy to use (see
getStrategy() ). | |||||||||||
Put the current test in asynchronous mode.
| |||||||||||
Cause this test to succeed during asynchronous mode.
| |||||||||||
A replacement for JUnit's
setUp() method. | |||||||||||
A replacement for JUnit's
tearDown() method. | |||||||||||
Runs the test via the
JUnitShell environment. | |||||||||||
This method has been made final to prevent you from accidentally running
client code outside of the GWT environment.
| |||||||||||
Returns true if this test case supports asynchronous mode.
| |||||||||||
This method has been made final to prevent you from accidentally running
client code outside of the GWT environment.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Records all live GWTTestCases by synthetic module name so we can optimize run they are compiled and run. Ordered so that we can precompile the modules in the order that they will run.
Object that collects the results of this test case execution.
A new instance of your subclass is constructed for each test method that is
to be run. You should avoid running code in your subclass constructor,
initializer blocks, and field initializations, because if those code blocks
must be runnable outside of the GWT environment. As an example of what
could go wrong if you run code there, trying to run a JSNI method could
generate an UnsatisfiedLinkError, and trying to call
create(Class)
could throw an
UnsupportedOperationException
. Instead, override
gwtSetUp()
and perform any initialization code there.
This method is deprecated.
implementation removed
Does nothing.
Determines whether or not exceptions will be caught by the test fixture.
Override this method and return false
to let exceptions escape
to the browser. This will break the normal JUnit reporting functionality,
but can be useful in Production Mode with a JavaScript debugger to pin down
where exceptions are originating.
true
for normal JUnit behavior, or false
to disable normal JUnit getException reporting
This method is deprecated.
implementation removed
Does nothing.
Get the names of all test modules.
This method is deprecated.
implementation removed
Returns a zero-length array.
Get the number of modules.
Specifies a module to use when running this test case. Subclasses must return the name of a module that will cause the source for that subclass to be included.
null
to run
as a pure Java (non-GWT) test case (same effect as passing
true
to setForcePureJava(boolean)
)Get the GWTTestCase.BaseStrategy
to use when compiling and running this test.
GWTTestCase.BaseStrategy
Get the synthetic module name, which includes the synthetic extension
defined by the GWTTestCase.BaseStrategy
.
null
if this test case
is run in pure Java mode (non-GWT)Get the set of all JUnitHost.TestInfo
for the specified module.
syntheticModuleName | the synthetic module name |
---|
Returns whether this test case should be run in pure Java mode (non-GWT).
Returns true
if and only if getModuleName()
returns
null
, or setForcePureJava(boolean)
was last invoked with
true
.
Stashes result
so that it can be accessed during
runTest()
.
Specifies whether this test case should be always run in pure Java mode
(non-GWT). Passing true
has the same effect as returning
null
in getModuleName()
. The setting is
false
by default.
forcePureJava | true to always run this test case in pure
Java mode (non-GWT); false to run this test case in GWT
mode if getModuleName() does not return null |
---|
Creates the test strategy to use (see getStrategy()
).
Put the current test in asynchronous mode. If the test method completes normally, this test will not immediately succeed. Instead, a delay period begins. During the delay period, the test system will wait for one of three things to happen:
finishTest()
is called before the delay period expires,
the test will succeed.TimeoutException
. This method is typically used to test event driven functionality.
Example: {@example com.google.gwt.examples.AsyncJUnitExample#testTimer()}
timeoutMillis | how long to wait before the current test will time out |
---|
UnsupportedOperationException | if supportsAsync() is false
|
---|
Cause this test to succeed during asynchronous mode. After calling
delayTestFinish(int)
, call this method during the delay period to
cause this test to succeed. This method is typically called from an event
handler some time after the test method returns control to the caller.
Calling this method before the test method completes, will undo the effect
of having called delayTestFinish()
. The test will revert to
normal, non-asynchronous mode.
Example: {@example com.google.gwt.examples.AsyncJUnitExample#testTimer()}
IllegalStateException | if this test is not in asynchronous mode |
---|---|
UnsupportedOperationException | if supportsAsync() is false |
A replacement for JUnit's tearDown()
method. This method runs once
per test method in your subclass, just after your each test method runs and
can be used to perform cleanup. Override this method instead of
tearDown()
. This method is run even in pure Java mode (non-GWT).
Exception |
---|
Runs the test via the JUnitShell
environment. Do not override or
call this method.
Throwable |
---|
This method has been made final to prevent you from accidentally running
client code outside of the GWT environment. Please override
gwtSetUp()
instead.
Exception |
---|
Returns true if this test case supports asynchronous mode. By default, this is set to true.
This method has been made final to prevent you from accidentally running
client code outside of the GWT environment. Please override
gwtTearDown()
instead.
Exception |
---|