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
Static method mocks incompatible with MockitoExtension (NotAMockException) #1967
Comments
Thanks for reporting. We already found the error, it slipped us. I think we can have a release ready fairly soon. |
raphw
added a commit
that referenced
this issue
Jul 12, 2020
raphw
added a commit
that referenced
this issue
Jul 12, 2020
raphw
added a commit
that referenced
this issue
Jul 12, 2020
raphw
added a commit
that referenced
this issue
Jul 13, 2020
raphw
added a commit
that referenced
this issue
Jul 16, 2020
truman-show
added a commit
to truman-show/caregiver-salrong
that referenced
this issue
Jun 12, 2021
- 3.4.0 -> 3.11.1 로 버전을 올렸습니다. - 3.4.0 은 static method을 사용할 때 MockitoExcension 과 호환되지 않는 이슈가 있습니다. - 발생 예외 : org.mockito.exceptions.misusing.NotAMockException: Argument passed to Mockito.mockingDetails() should be a mock, but is an instance of class java.lang.Class! - 이슈 : mockito/mockito#1967
truman-show
added a commit
to TuesdayGangnam/caregiver-salon
that referenced
this issue
Jun 13, 2021
- 3.4.0 -> 3.11.1 로 버전을 올렸습니다. - 3.4.0 은 static method을 사용할 때 MockitoExcension 과 호환되지 않는 이슈가 있습니다. - 발생 예외 : org.mockito.exceptions.misusing.NotAMockException: Argument passed to Mockito.mockingDetails() should be a mock, but is an instance of class java.lang.Class! - 이슈 : mockito/mockito#1967
ksankeerth
added a commit
to ksankeerth/shardingsphere
that referenced
this issue
Jan 30, 2022
In Mocktio 3.4.0, static mocks causes NotAMockException. They are fixed in 3.4.2. [1] : mockito/mockito#1968 [2]: mockito/mockito#1967
terrymanu
pushed a commit
to apache/shardingsphere
that referenced
this issue
Jan 30, 2022
* Fixed test cases of MySQLDataSourcePreparer (Git issue : 14246) * Changed the mockito version to 3.4.2 (Git issue : 14246) In Mocktio 3.4.0, static mocks causes NotAMockException. They are fixed in 3.4.2. [1] : mockito/mockito#1968 [2]: mockito/mockito#1967 * Fixed test MySQLDataSourcePreparerTest (Git issue : 14246)
I used @ExtendWith(SpringExtension.class) instead of MockitoExtension.class and it worked. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I am experimenting with the newly released functionality of mocking static methods.
It appears that static mocks are not compatible with the
MockitoExtension
designed for JUnit 5.Following error message is produced when using the extension:
Full Stacktrace: static-mock-mockito-extension-stacktrace.txt
I have created following minimal example which is composed of a
Utils
class (containing the static method) and aUtilsUser
class (calls the static Utils method).UtilsUserTest
tests the functionality of theUtilsUser
class.When converting this test to a test which does not use the extension (removing
@ExtendWith
, removing@InjectMocks
, adding= new UtilsUser()
after the field declaration), the test passes.Can you tell me if there is something special I have to accomodate for when using the static mocks in JUnit Jupiter?
Or is this indeed a bug (which you can hopefully reproduce)?
I am using mockito-inline and mockito-junit-jupiter in version 3.4.0.
Thanks in advance and thanks for the new static mocks functionality!
David
The text was updated successfully, but these errors were encountered: