public interface ABC {
public boolean removeUser(String userId) throws OTPServiceException, RemoteException;
}
ABC abc= mock(ABC.class);
doNothing().when(abc).removeUser(anyString());
私はこれを試しました。私は例外以下になった。非void
方法について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
あなたはあなたの質問が何であるか説明してください。 –
彼はあなたの質問が何であるか尋ねています。このメッセージは非常に明確です。「voidメソッドのみが何もできません!」だからあなたはGoogleにメッセージを送り、あなたの問題を解決しますか? – GhostCat