私はコンストラクタを持っています:
public PodLinksActivity( PodLinksPlace place ){
super( MFactory.getView(), place);
// other methods
}
GWTTestCase を作成しないために、PowerMock または PowerMockito (Mockito) で MFactory.getView() 静的メソッドをスタブするにはどうすればよいですか?
ありがとう!
// 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);
テスト クラスの先頭に適切な PowerMock 注釈を追加してください。
@RunWith(PowerMockRunner.class)
@PrepareForTest(MFactory.class)