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
- Remove mockito-core from spring-boot - Please help by suggesting how can it be done, without impacting the same dependency being added by Mockito-inline?
- There is a problem with my understanding - If this is the case, kindly help me understand it better, with probably an example of using Mockito with Spring-boot to mock static method
mockito-core
is pulled in byspring-boot-starter-test
. Just exclude it and addmockito-inline
as a test dependency.