Conflicting versions of ArgumentsProcessor in mockito-core and mockito-scala
See original GitHub issueorg.mockito.internal.invocation.ArgumentsProcessor
class exists in both mockito-core
and mockito-scala
projects with different API.
Since classloading order is unreliable both versions can be loaded. As a result, when mockito-core
’s version gets loaded first, there will be errors
java.lang.NoSuchFieldError: extractors
at org.mockito.ReflectionUtils$.markMethodsWithLazyArgs(ReflectionUtils.scala:19)
at org.mockito.MockitoEnhancer.mock(MockitoSugar.scala:122)
at org.mockito.MockitoEnhancer.mock$(MockitoSugar.scala:119)
Please consider moving or renaming mockito-scala
’s version.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Uses of Interface org.mockito.ArgumentMatcher - javadoc.io
Mocking progress stateful classes. org.mockito.internal.reporting. Deals with nicely printing verification errors. org.mockito.internal.verification.
Read more >ScalaTest and Mockito - unresolved dependency
Nope, i don't see any folder created for mockito. I have tried with different mockito versions as well, But its failing with the...
Read more >mockito-scala - Scaladex
All the mocks created will use ReturnsSmartNulls by default, this is different to the Java version, which returns null for any non-primitive or...
Read more >Introduction to mockito-scala — Part 1 | by Bruno Bonanno
This article series was written for the version 0.x.x of mockito-scala, and while the technical details and reasoning behind the new ...
Read more >Using ScalaTest With Mockito | Baeldung on Scala
In this tutorial, let's look at different ways in which we can use ... For using the Mockito version 3.4, we need to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Solved by #36 - mockito-scala 0.4.0
Well, it seems that it’s not consistent, I’ve created a dummy test project https://github.com/bbonanno/mockito-scala-as-dependency and it works as it is, but then if you add the
mockito-core
dependency, sometimes it works in SBT and not in the IDE and vice-versa depending in what order you put it, something surprising is that for some people it seems to work by putting themockito-core
dependency after themockito-scala
one (specs2 does something similar, so there are some StackOverflow posts about a very similar issue)So what I did is to make the by-name feature in PR #19 and I added the instructions in the readme in how to enable the feature in case you needed it/wanna fight the class loader, if you use version 0.0.14 you will find the fix
I hope @mockitoguy and I can add the necessary support in
mockito-core
soon so we don’t rely on the class loader hack anymore.