question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OutputCapture reset method is package-private

See original GitHub issue

Hello, 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:closed
  • Created 10 months ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
wilkinsonacommented, Nov 18, 2022

If you’re using Java 11 or later, java.lang.String.lines() is another option for getting each line from the captured output.

1reaction
philwebbcommented, Nov 18, 2022

systemCaptures holds a collection of SystemCapture 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(...) on CapturedOutput.getAll()

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found