question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conflicting versions of ArgumentsProcessor in mockito-core and mockito-scala

See original GitHub issue

org.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:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bbonannocommented, Aug 27, 2018

Solved by #36 - mockito-scala 0.4.0

0reactions
bbonannocommented, Aug 9, 2018

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 the mockito-core dependency after the mockito-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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found