Context: We are using Junit 5, Spring-Boot 2.6.3 Spring-Boot comes with its dependency on mockito-core
Problem
I am looking to create a mock for a static method. Mockito provides a library (mockito-inline) that allows mocking static methods, however, it works when mockito-core is not directly in dependency. Mockito-inline downloads the compatible mockito-core when required.
(ref: https://frontbackend.com/java/how-to-mock-static-methods-with-mockito)
Possible Solutions
According the documentation on Github.
It can be done via the mockito extension mechanism by creating the file src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker containing a single line:
mock-maker-inline
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With