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

Mockito Inline Mock Maker - throws Exception - Argument passed to when() is not a mock #2253

Closed
msnkishore opened this issue Apr 5, 2021 · 3 comments

Comments

@msnkishore
Copy link

msnkishore commented Apr 5, 2021

Hi,

I wanted to mock static methods, hence used dependency "mockito-inline" 3.8 version instead of "mockito-core"

The static method mocks work fine but my old tests that mock interfaces fail with the below error

org.mockito.exceptions.misusing.NotAMockException: Argument passed to when() is not a mock! Example of correct stubbing: doThrow(new RuntimeException()).when(mock).someMethod();

Reverting to using mockito-core solves the issue but then I would not be able to mock static methods

Is there any way we can choose different mockito engines (Subclass/Inline) for each class?

Regards
msn

@msnkishore
Copy link
Author

Duplicate of #1980, MockResolver fixed the issue

@Kosmo1
Copy link

Kosmo1 commented Dec 20, 2022

@msnkishore Exactly how did MockResolver fix the issue? I just ran into this same issue when using v3.4.0, and changing to v3.6.0 (which included #2042 and the MockResolver support) did not resolve the issue. Please tell me how to get Mockito to recognize @SpyBeans - thank you.

@woonys
Copy link

woonys commented Jan 22, 2024

@msnkishore I also faced the same issue with the version to v3.6.0.

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