public interface ABC {
public boolean removeUser(String userId) throws OTPServiceException, RemoteException;
}
ABC abc= mock(ABC.class);
doNothing().when(abc).removeUser(anyString());
我試過這樣。我得到了以下例外。Mockito拋出異常
org.mockito.exceptions.base.MockitoException:
Only void methods can doNothing()!
Example of correct use of doNothing():
doNothing().
doThrow(new RuntimeException())
.when(mock).someVoidMethod();
Above means:
someVoidMethod() does nothing the 1st time but throws an exception the 2nd time is called
你擔心什麼? – talex
你能解釋一下你的問題嗎? –
他問你你的問題是什麼。信息非常清楚「只有無效的方法才能做到沒有()!」所以你谷歌消息並解決你的問題?! – GhostCat