« Peace on you! | Main | Populating Test Data for GWT Tests »
Sunday
Feb082009

Getting Rid of Flakiness in GWT RPC Tests

To avoid flaky RPC testing in GWT tests, use fake service implementation which you inject directly into the constructor of your custom widget. There will be no delays, and you will be in complete control.

with real servicewith injected fake service
public void testSomethingHappened() {
CustomWidget w = new CustomWidget();
w.doSomethingThatTriggersRpcCall();

Timer timer = new Timer() {
public void run() {
assertTrue(widget.somethingHappened());
finishTest();
}
};
timer.schedule(200);
delayTestFinish(500);
}

public void testSomethingHappened() {
Service fake = new FakeService();
CustomWidget w =
new CustomWidget(fake);
w.doSomethingThatTriggersRpcCall();
assertTrue(widget.somethingHappened());
}

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>