OutputCapture reset method is package-private
See original GitHub issueHello, I’m currently trying to utilize OutputCapture
in my unit testing to test logging level. And I face issue that I’m not able to reset OutputCapture
, but according this pull request this functionality should be implemented. My spring-boot version is 2.7.4.
Probably, I can change fixture of test every time by using @TestInstance(TestInstance.Lifecycle.PER_METHOD)
, but I suppose that is not the best solution.
I suppose, adding any functionality to check logging level would be a very good contributing as well.
Issue Analytics
- State:
- Created 10 months ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Split JUnit 5 OutputCapture into extension and captured output
The new OutputCapture class introduced in #14738 currently acts as both the extension and the captured output. This has the unfortunate ...
Read more >OutputCaptureRule (Spring Boot Test 2.2.1.RELEASE API)
All Methods Instance Methods Concrete Methods Deprecated Methods ... Resets the current capture session, clearing its captured output.
Read more >java - Spring feature OutputCapture does not work in valid ...
I cannot use the feature with OutputCapture within JUnit testing. I want to use this feature to see some log messages.
Read more >OutputCapture (Spring Boot Docs 1.4.7.RELEASE API)
@Deprecated public class OutputCapture extends OutputCapture ... Methods inherited from class org.springframework.boot.test.rule.OutputCapture.
Read more >How to use OutputCapture in org.springframework.boot.test.rule
getForObject("/messages", String[].class); // Then // We expected MDC data to appear on each log line - even from @Async methods... // - Logged...
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
If you’re using Java 11 or later,
java.lang.String.lines()
is another option for getting each line from the captured output.systemCaptures
holds a collection ofSystemCapture
instance, but these don’t necessarily relate to lines. They are rather a block of captured bytes (which may or may not be a complete line). I think we should keep this internal to the class.If you want to to do per line assertions you can do
.spit(...)
onCapturedOutput.getAll()