I am using private static final LOGGER field in my class and I want LOGGER.isInfoEnabled() method to return false. How can
The accepted solution shouldn't work with JDK 12. The reason can be seen here.
It is easy to do it using PowerMockito (tested with version 2.0.9). You can use the Whitebox.setInternalState method to do it for you.
Example:
Whitebox.setInternalState(MyTestClass.class, "myCar", carMock);
MyTestClass is the class containing the field.
myCar is the variable name of the field.
carMock is some mock you want to pass.