- 验证调用测试类自己的方法,使用spy方法
@Test
public void should_resetInfo_when_auto() throws Exception {
//given
Presenter presenter=spy(Presenter.class);
//when
presenter.auto("000222");
//then
verify(presenter).resetInfo("000222");
}
- 验证是否正确调用其他类方法 , 使用verify
@Test
public void should_setInfo_when_resetInfo() throws Exception {
//given
Presenter presenter=new Presenter() ;
View view = mock(View.class);
//when
presenter.resetInfo("000222");