I have a constructor:
public PodLinksActivity( PodLinksPlace place ){
super( MFactory.getView(), place);
// other methods
}
how can I stub the MFactory.getView() static method with PowerMock or PowerMockito (Mockito) for not making a GWTTestCase?
Thanks开发者_StackOverflow社区!
// view you expect to pass as first super-arg
View view = mock(View.class);
// setup the MFactory class
PowerMockito.mockStatic(MFactory.class);
// mock the method you care about
PowerMockito.when(MFactory.class, "getView").thenReturn(view);
Ensure that you add the appropriate PowerMock annotations at the top of your test class:
@RunWith(PowerMockRunner.class)
@PrepareForTest(MFactory.class)
精彩评论