java.lang.Object | |
↳ | com.google.gwt.junit.GWTMockUtilities |
Defangs create(Class)
to allow unit tests to mock out Widgets and
other UIObjects.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Replace the normal GWT.create() behavior with a method that returns null
instead of throwing a runtime exception.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Replace the normal GWT.create() behavior with a method that returns null instead of throwing a runtime exception. This is to allow JUnit tests to mock classes that make GWT.create() calls in their static initializers. This is not for use with GWTTestCase, and is not for use testing widgets themselves. Rather, it is to allow pure java unit tests of classes that need to manipulate widgets.
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); }