I'm upgrading my code from Java v1.8 to v11.0.8. All went fine until I run the tests mvn test
and Mockito starts having issues. Every test errors-out.
My versions of Mockito are fine (2.23.4) according to other answers here so I go to run just 1 test to narrow down the problem - it runs fine. So I run all the tests by right-clicking in Eclipse on my src/test/java and choosing Run As > JUnit test. Again, all run fine.
Note: I hesitate to add the error message here because the code works (as noted above), so this can be a distraction, but this question got a close request for lack of error message!
You are seeing this disclaimer because Mockito is configured to create inlined mocks.
You can learn more about inline mocks and their limitations under #39 of the Mockito class javadoc
Underlying exception: org.mockito.exceptions.base.MockitoException: Could not modify all classes [..., ..., ...]
at ...
at ...
Caused by org.springframework.beans.BeanInstantiationException: Failed to instantiate [..]: Factory method '...' threw exception; nested exception is org.springframework.beans.BeanCreationException: Error creating bean with name '...' defined in...
Mockito cannot mock this class: ...
If you're not sure why you're getting this error, please report to the mailing list.
The app itself runs fine with springboot:run clean
My tests always ran with only test
as the goal, that is confirmed for me here, so what's changed?
I also see references to: Bytebuddy in that article but I have a good version of that too (1.9.16)