My class uses a static local variable of org.slf4j.Logger
. Is there some clever way of replacing this with a mock object for my testing? I'm thinking my best option is for MyClass
to expose a setter?
Also, how can I mock the Logger object? I'd like to mock it such that when LOGGER.error(string, exception)
is called I'd like to validate the error String.
public class MyClass {
private static Logger LOGGER = LoggerFactory.getLogger(MyClass.class);