TestCase API.
The two key methods are GWTTestCase.delayTestFinish(int) and
GWTTestCase.finishTest(). Calling delayTestFinish()
during a test method's execution puts that test in asynchronous mode,
which means the test will not finish when the test method returns control
to the caller. Instead, a delay period begins, which lasts the
amount of time specified in the call to delayTestFinish().
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.
The normal use pattern is to setup an event in the test method and call
delayTestFinish() with a timeout significantly longer than
the event is expected to take. The event handler validates the event and
then calls finishTest().
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);
}
delayTestFinish() again with a new timeout and trigger the
next event. When the last event fires, call finishTest()
as normal. testFinish()
when the counter reaches 0.