You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@ExtendWith(SpringExtension.class)
@SpringBootTest(
classes = { Bla.class },
webEnvironment = WebEnvironment.NONE)
@ActiveProfiles("test")
@LogCollectorExtension
public class FooTest {
...
Logger logger = LoggerFactory.getLogger(Foo.class);
JUnit5LogCollector collector = new JUnit5LogCollector(logger);
...
@Test
public void testFoo() {
doSomethingWithFoo();
// NPE happens here
collector.getLogs().stream().forEach(log -> System.out.println(log));
}
...
}
It dies with:
java.lang.NullPointerException
at dk.bitcraft.lc.Log4j2Collector.getResult(Log4j2Collector.java:41)
at dk.bitcraft.lc.JUnit5LogCollector.getLogs(JUnit5LogCollector.java:28)
at com.acme.FooTest.testFoo(FooTest.java:131)
Seems like the appender in Log4j2Collector isn't properly initialized. Maybe somehow setup() isn't called properly?
The text was updated successfully, but these errors were encountered:
I found out that the @LogCollectorExtension annotation is ignored as soon as there is another @ExtendWith annotation. That means that the collector is not initialized.
That would not be that big problem if @JUnit5LogCollectorExtension wouldn't be package scoped so that it could be used directly with a present @ExtendWith annotation.
Just tried the following:
It dies with:
Seems like the
appender
inLog4j2Collector
isn't properly initialized. Maybe somehowsetup()
isn't called properly?The text was updated successfully, but these errors were encountered: