Okay I found out that I had to modify the test. Now it the test looks
like this:
----------------------------------------------------------
public class MainTest extends GWTTestCase implements AsyncCallback {
public String getModuleName() {
return "junitGWT.Main";
}
public void testSimple() {
assertTrue(true);
}
public void onSuccess( Object result ) {}
public void onFailure( Throwable caught ) {}
public void testTextService() {
final Main main = new Main();
TextServiceAsync textService = ( TextServiceAsync )
GWT.create( TextService.class );
ServiceDefTarget target = (ServiceDefTarget) textService;
target.setServiceEntryPoint( GWT.getHostPageBaseURL() +
"TextServiceImpl");
textService.setupSessionObject( this );
Timer timer = new Timer() {
public void run() {
main.getTextFromServer("codeword");
//here I need a delay.
assertEquals( "success" , main.textFromServer );
finishTest();
}
};
delayTestFinish(500);
timer.schedule(300);
}
}
----------------------------------------------------------
The Main class looks like this (at least the interesting part):
----------------------------------------------------------
public class Main implements EntryPoint, AsyncCallback {
...
public void getTextFromServer( String option ) {
textService.getText( option , this);
}
public void onFailure( Throwable caught ) {
label.setText(caught.getMessage());
}
public String textFromServer = null;
public void onSuccess( Object result ) {
if( result != null ) {
label.setText( (String) result );
textFromServer = (String) result;
} else {
textFromServer = null;
label.setText( "null" );
}
}
-------------------------------------------------------------
Now the run method of my Timer object in the TestCase is executed but
the test fails anyway. The problem is that I need some kind of delay
before assertEquals( "success" , main.textFromServer ); is called. I
manually added a Window.alert and waited a short time before clicking
okay. Then it worked. But in automated mode if fails.
How can this be solved?
On Jul 5, 11:47 am, Paul van Hoven <
paul.van.ho...@googlemail.com>
wrote: