public class GWTMockUtilities extends Object
GWT.create(Class)
to allow unit tests to mock out Widgets and
other UIObjects.Constructor and Description |
---|
GWTMockUtilities() |
Modifier and Type | Method and Description |
---|---|
static void |
disarm()
Replace the normal GWT.create() behavior with a method that returns null
instead of throwing a runtime exception.
|
static void |
restore() |
static void |
returnMockMessages()
After
disarm() replaces the normal GWT.create(), this method
enables Messages to be faked out. |
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()
public static void returnMockMessages()
disarm()
replaces the normal GWT.create(), this method
enables Messages to be faked out. The fake instance creation is delegated
to FakeMessagesMaker
.Copyright © 2016. All rights reserved.