I am trying to figure out exactly how mockito selects its mock maker:
I participate in an effort to migrate a very large maven build from maven to gradle.
An issue popped in the migration effort, in the gradle build we seem to be unable to spy final classes even though the very same tests compiled with maven work just fine.
I assume it is a dependency resolution issue of some kind but I have been unable to pinpoint it for now, we have a pretty large classpath so identifying relevant libs is not trivial. I couldn't find a way to debug the mockmaker selection in the mockito FAQ or documentation and stack overflow didn't yield anything interesting (or I failed to recognize it)
Here is what I am certain of at the moment:
- Both builds were run on JDK 11
- Both builds use the following exact dependencies during runtime:
- mockito 3.12.4
- byte buddy 1.9.16
- byte byddy agent 1.11.22
- objenesis 3.2
- mockito-junit-jupiter 3.12.4
- junit-jupiter-api 5.8.2
Neither build declares a dependency on mockito-inline which I have seen mentionned multiple times when researching the error message. It is unclear to me if the mockito inline dependency is for mockito 2 only or if it still applies to mockito 3+,
I assume that since the test works with maven, the dependency is not actually required for our use case.
the spy error on gradle popped for 2 different classes :
- one java class which is explicitly marked final
- one kotlin class which is implicitely final (since it is not marked open)
Any pointers on next steps to understand what's going on will be very appreciated