Strange NoSuchMethodError when using 2.2.0
See original GitHub issueI’ve been trying to upgrade from 2.1.0
to 2.2.0
and now I have a few tests that fail with this exception:
java.lang.NoSuchMethodError: com.nhaarman.mockitokotlin2.MockingKt.withSettings([Lkotlin/reflect/KClass;Ljava/lang/String;Ljava/lang/Object;Lorg/mockito/stubbing/Answer;ZLorg/mockito/mock/SerializableMode;Z[Lorg/mockito/listeners/InvocationListener;ZLcom/nhaarman/mockitokotlin2/UseConstructor;Ljava/lang/Object;Z)Lorg/mockito/MockSettings;
at com.qonto.qonto.ui.otp.setup.phonenumber.PhoneNumberPresenterTest.<init>(PhoneNumberPresenterTest.kt:180)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
This is on a test that does something like this:
private val otpViewModel = mock<OTPSetupViewModel> {
on { mustSwitchOtpFromAppToSms() } itAnswers { mustSwitchOtpFromAppToSms }
on { createMfaBySms() } itAnswers { createMfaBySmsResponse }
on { showError } itAnswers { showErrorLiveData }
}
Any idea?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:14 (1 by maintainers)
Top Results From Across the Web
Strange NoSuchMethodError when using 2.2.0 #364 - GitHub
I've been trying to upgrade from 2.1.0 to 2.2.0 and now I have a few tests that fail with this exception: java.lang.NoSuchMethodError: ...
Read more >google errorprone java.lang.NoSuchMethodError
We find out the dependency using this command ./gradlew -q dependencyInsight --configuration errorprone --dependency error_prone_core.
Read more >PlayFramework Slick NoSuchMethodError - Google Groups
Im having strange problem while using new slick version with mysql: [RuntimeException: java.lang.NoSuchMethodError: slick.driver.JdbcProfile$API.
Read more >Solved: Exception (noSuchMethodError) trying to run ML exa...
Solved: Hi, i'm having a strange exception when i try to run ml example in Zeppelin: here is the exception: - 192045.
Read more >NoSuchMethodError updating to Prosys-OPC-UA-Java-SDK ...
I'm working to update my Java OSGi based application developed with Prosys OPC UA SDK Client 2.0.0-194 to SDK version 2.2.0-552.
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
I had the same issue and we also use Kluent. In this Test it turned out we used the mock method from Kluent instead of mockitotokotlin and with that we got:
java.lang.NoSuchMethodError: com.nhaarman.mockitokotlin2.MockingKt.withSettings([Lkotlin/reflect/KClass;Ljava/lang/String;Ljava/lang/Object;Lorg/mockito/stubbing/Answer;ZLorg/mockito/mock/SerializableMode;Z[Lorg/mockito/listeners/InvocationListener;ZLcom/nhaarman/mockitokotlin2/UseConstructor;Ljava/lang/Object;)Lorg/mockito/MockSettings;
After changing from
import org.amshove.kluent.mock to
import com.nhaarman.mockitokotlin2.mockthe test works fine.
See #408 as well for updated dependencies.