-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling getExceptionTypes() on concrete object that is used as interface doesn't return exception types from interface #2201
Comments
Hi @TimvdLippe ! |
isn't it expected behavior? the same issue(?) will happen when mocking a class with interface /parent class with additional method exception . From the implementation perspective
|
…hen parent contains throws keyword on its method and child overrides this method removing throws, it should be possible to mock throwing exception from child
…hen parent contains throws keyword on its method and child overrides this method removing throws, it should be possible to mock throwing exception from child
…hen parent contains throws keyword on its method and child overrides this method removing throws, it should be possible to mock throwing exception from child
…hen parent contains throws keyword on its method and child overrides this method removing throws, it should be possible to mock throwing exception from child
org.mockito.internal.stubbing.answers.InvocationInfo#isValidException is doing validation on the exception types that can be thrown from this method.
In my codebase, I'm programming against an interface, but in fact, a spy is created from an instance that is implementing the interface, that drops the exception types that that implementation does not throw. However, the code that is calling the interface is of course unaware of that fact. Also, that implementation is a mock implementation (a real mock implementation, not a Mockito mock()/spy() instance).
A testcase here:
The text was updated successfully, but these errors were encountered: