Assume I have a class that throw ClassNotFoundException like this:
public class RealOne {
public void funcA() {
try {
...
}
catch( ClassNotFoundException e ) {}
}
}
When I unit test this method like this:
@Test(expected=ClassNotFoundException.class)
public void testingClassNotFoundException() {
stubber.funcA();
}
I get following error:
java.lang.Exception: Unexpected exception, expected<java.lang.ClassNotFoundException> but was<org.mockito.exceptions.base.MockitoException>
...
...
Caused by: org.mockito.exceptions.base.MockitoException:
Checked exception is invalid for this method!
Invalid: java.lang.ClassNotFoundException
May I know how could I expect ClassNotFoundException but not MockitoException?