|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.gwt.junit.GWTMockUtilities
public class GWTMockUtilities
Defangs GWT.create(Class) to allow unit tests to mock out Widgets and
other UIObjects.
| Constructor Summary | |
|---|---|
GWTMockUtilities()
|
|
| Method Summary | |
|---|---|
static void |
disarm()
Replace the normal GWT.create() behavior with a method that returns null instead of throwing a runtime exception. |
static void |
restore()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GWTMockUtilities()
| Method Detail |
|---|
public static void disarm()
NOTE: Be sure to call restore() in your tearDown
method, to avoid confusing downstream tests.
Sample use:
@Override
public void setUp() throws Exception {
super.setUp();
GWTMockUtilities.disarm();
}
@Override
public void tearDown() {
GWTMockUtilities.restore();
}
public void testSomething() {
MyStatusWidget mock = EasyMock.createMock(MyStatusWidget.class);
EasyMock.expect(mock.setText("expected text"));
EasyMock.replay(mock);
StatusController controller = new StatusController(mock);
controller.setStatus("expected text");
EasyMock.verify(mock);
}
public static void restore()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||