Is OutputCaptureExtension supposed to support java.util.logging too?
See original GitHub issueHi, 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
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.logging.AbstractLoggingSystemTests;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import java.util.logging.Logger;
import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(OutputCaptureExtension.class)
public class TestCapture extends AbstractLoggingSystemTests {
static Logger LOG=Logger.getLogger(TestCapture.class.getName());
@Test
void test(CapturedOutput output) {
System.out.println("ok");
LOG.warning("error");
assertThat(output).contains("ok");
assertThat(output).contains("error");
}
@Test
void test2(CapturedOutput output) {
LOG.info("not ok");
LOG.warning("type 1 error");
assertThat(output).contains("not");
assertThat(output).contains("type 1");
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Package java.util.logging - Oracle Help Center
The central goal of the logging APIs is to support maintaining and servicing software at customer sites. There are four main target uses...
Read more >Do you find java.util.logging sufficient? [closed] - Stack Overflow
In summary, Java JDK logging is fine, but a standardized API that is used in my third party libraries will save you time...
Read more >How To Unit Log Statements With JUnit 5 - Callibrity
This post is to demonstrate how to use JUnit 5 Extensions to help unit test log statements, along with providing sample code via...
Read more >Java Logging Guide: The Basics | CrowdStrike
In this overview, we introduce the basic logging concepts for Java applications as well as available logging frameworks and their supported ...
Read more >Replacing logging APIs with the Java System Logger
Log4j2. Log4j2 has a module, log4j-jpl , that is supposed to add support for the JDK System.Logger . By placing ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
follow=true
when configuring a Log4j2 console appender.Awesome! Thanks