-
Notifications
You must be signed in to change notification settings - Fork 239
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
Method not mocked at partial mock #84
Comments
Thanks. The third test should fail with a proper validation failure; I will fix this. |
I don't understand why the test should fail. From the following test code I supposed that it is legal code for a jmockit test. Please can you explain, what is wrong with my above assumptions and why the test should fail with a validation failure as you mentioned in your comment!
|
Yes, but all methods from AbstractClass do get mocked. The only problem was that in the third test, the "new NonStrictExpectations( implementationClass )" call caused JMockit to get into an inconsistent state regarding the mocking of the base class. But the real problem here is not that, but the fact that this partial mocking call shouldn't have been accepted in the first place; it should instead have triggered an "InvalidArgumentException: class AbstractClass is already mocked". This is the fix I am applying, to tighten up the validation against duplicate mockings which already is in place, so that it also checks the super-classes. You probably want to write "@tested @mocked ImplementationClass implementationClass". This should provide all that's needed for the tests. |
Thank you for the explanation! With the @tested annotation it works for me as expected. |
In the following example code one test fails because the real method is called, although the class that declares the method is mocked. It occurs if the tested class instance is partially mocked and a sub class of the mocked class.
The text was updated successfully, but these errors were encountered: