|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
com.google.gwt.junit.client.GWTTestCase
public abstract class GWTTestCase
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.
Field Summary | |
---|---|
protected junit.framework.TestResult |
testResult
|
Constructor Summary | |
---|---|
GWTTestCase()
A new instance of your subclass is constructed for each test method that is to be run. |
Method Summary | |
---|---|
void |
addCheckpoint(java.lang.String msg)
Deprecated. This method will be removed when web mode supports stack traces. It can be useful for debugging web mode failures, but production code should not depend on it. |
boolean |
catchExceptions()
Determines whether or not exceptions will be caught by the test fixture. |
void |
clearCheckpoints()
Deprecated. This method will be removed when web mode supports stack traces. It can be useful for debugging web mode failures, but production code should not depend on it. |
protected void |
delayTestFinish(int timeoutMillis)
Put the current test in asynchronous mode. |
protected void |
finishTest()
Cause this test to succeed during asynchronous mode. |
java.lang.String[] |
getCheckpoints()
Deprecated. This method will be removed when web mode supports stack traces. It can be useful for debugging web mode failures, but production code should not depend on it. |
abstract java.lang.String |
getModuleName()
Specifies a module to use when running this test case. |
protected void |
gwtSetUp()
A replacement for JUnit's setUp() method. |
protected void |
gwtTearDown()
A replacement for JUnit's tearDown() method. |
void |
run(junit.framework.TestResult result)
Stashes result so that it can be accessed during
runTest() . |
protected void |
runTest()
Runs the test via the JUnitShell environment. |
protected void |
setUp()
This method has been made final to prevent you from accidentally running client code outside of the GWT environment. |
protected boolean |
supportsAsync()
Returns true if this test case supports asynchronous mode. |
protected void |
tearDown()
This method has been made final to prevent you from accidentally running client code outside of the GWT environment. |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, runBare, setName, toString |
Methods inherited from class junit.framework.Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected junit.framework.TestResult testResult
Constructor Detail |
---|
public GWTTestCase()
UnsatisfiedLinkError
, and trying to call
GWT.create(Class)
could throw an
UnsupportedOperationException
.Instead, override
gwtSetUp()
and perform any initialization code there.
Method Detail |
---|
@Deprecated public final void addCheckpoint(java.lang.String msg)
msg
- the checkpoint message to addpublic boolean catchExceptions()
false
to let exceptions
escape to the browser. This will break the normal JUnit reporting
functionality, but can be useful in web 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@Deprecated public final void clearCheckpoints()
addCheckpoint(String)
@Deprecated public final java.lang.String[] getCheckpoints()
null
array of checkpoint messagesaddCheckpoint(String)
public abstract java.lang.String getModuleName()
public final void run(junit.framework.TestResult result)
result
so that it can be accessed during
runTest()
.
run
in interface junit.framework.Test
run
in class junit.framework.TestCase
protected final void delayTestFinish(int timeoutMillis)
finishTest()
is called before the delay period expires,
the test will succeed.TimeoutException
. This method is typically used to test event driven functionality.
Example:
public void testTimer() { // Setup an asynchronous event handler. Timer timer = new Timer() { public void run() { // do some validation logic // tell the test system the test is now done finishTest(); } }; // Set a delay period significantly longer than the // event is expected to take. delayTestFinish(500); // Schedule the event and return control to the test system. timer.schedule(100); }
timeoutMillis
- how long to wait before the current test will time out
java.lang.UnsupportedOperationException
- if supportsAsync()
is falsefinishTest()
protected final void finishTest()
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:
public void testTimer() { // Setup an asynchronous event handler. Timer timer = new Timer() { public void run() { // do some validation logic // tell the test system the test is now done finishTest(); } }; // Set a delay period significantly longer than the // event is expected to take. delayTestFinish(500); // Schedule the event and return control to the test system. timer.schedule(100); }
java.lang.IllegalStateException
- if this test is not in asynchronous mode
java.lang.UnsupportedOperationException
- if supportsAsync()
is falsedelayTestFinish(int)
protected void gwtSetUp() throws java.lang.Exception
setUp()
method. This method runs once
per test method in your subclass, just before your each test method runs
and can be used to perform initialization. Override this method instead of
setUp()
.
java.lang.Exception
protected void gwtTearDown() throws java.lang.Exception
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()
.
java.lang.Exception
protected void runTest() throws java.lang.Throwable
JUnitShell
environment. Do not override or
call this method.
runTest
in class junit.framework.TestCase
java.lang.Throwable
protected final void setUp() throws java.lang.Exception
gwtSetUp()
instead.
setUp
in class junit.framework.TestCase
java.lang.Exception
protected boolean supportsAsync()
protected void tearDown() throws java.lang.Exception
gwtTearDown()
instead.
tearDown
in class junit.framework.TestCase
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |