KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am testing a method with an expected exception. I also need to verify that some cleanup code was called (on a mocked object) after the exception is thrown, but it looks like that verification is being ignored. Here is the code. I am using the Junit ExpectedException Rule to verify the expected exception. @Rule public ExpectedException expectedEx = ExpectedException.none(); @Test public void testExpectedException() { MockedObject mockObj = mock(MockedObj.class); MySubject subject = new MySubject(mockedObj); expectedEx.expect(MyException.class); expectedEx.expectMessage("My exception message."); subject.someMethodThrowingException(); verify(mockObj). someCleanup(eq(...)); } It seems like the verify is totally being ignored. No matter what method I put in the verify , my test is passing, which is not what I want. Any idea why thats happenning?
Tags (comma-separated)
Save Edits
Cancel