java - Mockito How to mock and assert a thrown exception? - Stack Overflow
Make the exception happen like this:
when(obj.someMethod()).thenThrow(new AnException());
Verify it has happened either by asserting that your test will throw such an exception:
@Test(expected = AnException.class)
Or by normal mock verification:
verify(obj).someMethod();
Read full article from java - Mockito How to mock and assert a thrown exception? - Stack Overflow
No comments:
Post a Comment