I got a view (GWT MVP pattern) that contains a listbox.
I created a testcase using @Mock MyView viewThen in one test I want to be able to have a hand on the list box object using :
ListBox listBox = GwtReflectionUtils.getPrivateFieldValue(view, "tableListBox");
This returns null.
I followed this tutorial : http://code.google.com/p/gwt-test-utils/wiki/SimpleUnitTest which using the same way.
The only difference I see is I’m using UIBinder, however it should be supported from what I’ve read.
Thanks!
You are using a mock, of course fields aren’t set. When working with mocks you have to think about interactions, not state. (Actually this statement is true with generated mocks like those of mockito, powermock, easymock, etc.)
The wiki links examples don’t use mocks, they show real objects!
I think you will be more interested by a spy. You can use @Spy.
In mockito 1.9.0 you can write :
or if MyView has default constructor
For more information take a look at the javadoc.
Hope that helps.