I've started using Lombok fairly recently compared to many of you....and I am in the process of updating some code that is a few years old. As my very first step, I have added Lombok to set up the slf4j logger (and I am using a lombok.config file to rename the variable to LOGGER vs. log, so my existing code still works). When I run my tests, it fails when stating that LOGGER cannot be resolved. Here is a snippet of how I set up my capture:
@Mock private Appender mockAppender;
@Captor private ArgumentCaptor<LoggingEvent> captorLoggingEvent;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
this.carp = spy(new MyCodeProcessor(mock(MyClass.class), mock(AnotherClass.class), mock(AndOneMoreClass.class)));
//setup the logger so I can verify what is output to the logfile
Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.addAppender(mockAppender);
root.setLevel(Level.INFO);
}
I know that this code did work previously, so I am fairly certain it is related to adding Lombok to the mix. Has anyone tried to do log capturing as a part of their tests with Lombok. Before anyone complains that this is not proper testing, the code should be refactored, etc. This is not my priority at this time - I just wanted to start the process with what I thought was simple - adding Lombok for the logging before moving on to the rest of the refactoring that has to get done.
Thanks in advance,
Sharon