-
Notifications
You must be signed in to change notification settings - Fork 0
Integration with Guice
Since a GWT application usually deals with a backend server, you may be interested in using Guice to manage your server side components, like RPC services.
gwt-test-utils comes with some classes to allow you to test your entire GWT + Guice stack very easily.
@GwtModule("com.googlecode.gwt.test.sample.GuiceSample")
public class GuiceSampleTest extends GwtGuiceTest {
@Inject
private MyService myService;
// your test methods go here...
}
- First, extend
GwtGuiceTest
, the base class for test with Guice. - Like with
GwtTest
, you have to set the module under test with the@GwtModule
annotation. - That's it !
Your GwtGuiceTest
subclasses can be injected with @Inject
members, and hold a reference to the used Injector
through the GwtGuiceTest.getInjector()
protected method.
Also note that your RPC servlets will automatically be binded to their corresponding RemoteService
interfaces !
If you want to write a CSV test scenario which should be integrated with Guice, just extend GwtGuiceCsvTest
instead of GwtGuiceTest
:-)
You can fork sample-guice and sample-guice-csv projects to see complete GWT + Guice applications and how to test them using gwt-test-utils.
TODO