The following code results in org.mockito.exceptions.misusing.MissingMethodInvocationException:
Level level = mock(Level.class);
IOException ioException = new IOException("test");
when(level.getSyslogEquivalent()).thenThrow(ioException);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Did you check the
MissingMethodInvocationExceptionexception message ?It says :
Either the class
Levelis final (clearly not as I remember extending this class) or thegetSyslogEquivalentis final (best guess).So you should either revise your design or test design or maybe try Powermock, which offers final class/method mocking.
Hope that helps