Skip to content
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

Using import org.amshove.kluent.mock leads to a java.lang.NoSuchMethodError in mockitokolin #168

Closed
jleidgens opened this issue Oct 31, 2019 · 5 comments

Comments

@jleidgens
Copy link

I updated mockitokotlin2 to 2.2.0 and after that we saw unit tests failing with

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;

This only happened in cases where autocomplete mixed up the mock functions and we where using org.amshove.kluent.mock once we switched to com.nhaarman.mockitokotlin2.mock the tests go through again.

There is also a ticket inside the mockitokotlin repository about this.

@MarkusAmshove
Copy link
Owner

What would we have to do on our end to resolve this?

Is it enough to update the mockitokotlin version?

@jleidgens
Copy link
Author

I'm not sure what is causing this exception, it is definitely a bug in mockito that is happening this way but it still could be a wrong usage of the mockito library.

@MarkusAmshove
Copy link
Owner

Did you try to update mockitokotlin/mockito in Kluent and see what happens?
Otherwise I can try to give it a shot if you could create a small repro which uses Kluent and encounters this problem. Then I can rebuild Kluent locally and see if any updates fix this issue

@glureau-betclic
Copy link

Reproduced the same issue with latest version of mockito and mockito-kotlin + Kluent. Problem is the call mock() offers 2 imports to different implementations. I've removed the kluent one manually. Not sure why Kluent provides this mock method, should we not use the one provided by mockito directly @MarkusAmshove?

drcolombo added a commit to drcolombo/Kluent that referenced this issue Jan 6, 2021
…e and moved Mocking tests into the unit tests from the main Kluent code
@MarkusAmshove
Copy link
Owner

Should be fixed with version 1.65. if not feel free to reopen :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants