-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe quirks of JUL and Log4j2 in the javadoc of OutputCaptureExtension #32562
Comments
We've seen issues relating to log configuration in the past, for example #27902 (comment). Can you please share a sample application that replicates the issue so we can see exactly how your logs are being configured. |
Thanks for the quick response. I didn't use log4j. The code above is able to replicate the issue. |
Although the snippet above might replicate the issue, it would be best if we could have a sample application. That way we know that we're aligned on logging configurations and dependency versions. |
Thanks for the sample. The problem is with Our To get things working, you can add the following to your tests: @AfterEach
void reset() throws Exception {
LogManager.getLogManager().readConfiguration();
} That will force all handles to get closed so the next run will capture the correct |
Flagging for team attention to see if we should try and do this automatically in the |
Awesome! Thanks |
I don't think we should do this automatically, but I think it would be worth mentioning it in the javadoc. We could also mention the need for |
@wilkinsona can you briefly explain why |
Without |
same issue happening when you run tests in parallel and you have Logback and Sl4j setup in your project. In some cases the test method will have a captured output with dirty context and the assertion will fail. Will try to create a test scenario to share here |
@fokion Did the latest fix address the issue for you? I am also not using log4j and app uses log back, if my tests runs after any test that involves @SpringBootTest the my unit test that involves output capture extension fails because output is empty. When I run the test alone it passes. I have lombok’s @slf4j on my test subject and adding quirks mentioned above did not help at all. Also interesting that sometimes my tests are passing on CI, they are flaky now. I am suspecting that either a class loading order changes the behaviour or a delay happens somewhere else that causes assertion failure before the log entry arrives to the console through the appender. |
Hi, I ran into this problem below:
For each test, it passes. But if I run the test class, it always failed on the 2nd. Any ideas?
Thanks
The text was updated successfully, but these errors were encountered: