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
Allow @MockitoSettings to be inherited #1853
Comments
Feel free to send a PR with a fix. Awesome issue description :) |
Hi @TimvdLippe I am currently using the mockito-junit-jupiter v3.2.4 and I can see that
Do you know when, or, if there is any plans to release a new version of mockito-junit-jupiter containing this improvement? For now I am including the annotation on each test, but it would be great to refactor and keep it on just my AbstractTest class. |
New version should be pushing to Maven Central as we speak: 0a3064d |
@TimvdLippe That's awesome! Unfortunately Travis is not very happy:
|
That's sadly a known issue with Maven Central, but the artifact should be installable for you: https://repo1.maven.org/maven2/org/mockito/mockito-core/3.3.0/ |
Note that some configuration are impossible to mock via Mockito
(same as any question on stackoverflow.com)
I have a base test class which among other things mocks a "serviceLocator" and a very common class used by many other services:
But whenever any test try to mock the get method of this serviceLocator with a different class I get an UnnecessaryStubbingException:
Then I specify the strictness in the base test class
But even though the strictness is not seen by mockito.
I have debugged the code and found that the strictness is retrieved by searching the annotation on the method and the class of the test
mockito/subprojects/junit-jupiter/src/main/java/org/mockito/junit/jupiter/MockitoExtension.java
Lines 143 to 145 in b2b66f4
This eventually calls
https://github.com/junit-team/junit5/blob/5e41ebe612fd67e905f96f1dd3184a071b65be17/junit-platform-commons/src/main/java/org/junit/platform/commons/util/AnnotationUtils.java#L108-L112
So if you annotate
MockitoSettings
withjava.lang.annotation.Inherited
it will work (I turned the inherited variable to true using the debugger to confirm).For now I will have to annotate every test class with
I am using Gradle 7.0 with JUnit 5.5.2
Thanks
The text was updated successfully, but these errors were encountered: