This version is still in development and is not considered stable yet.
For the latest stable version, please use JUnit 6.0.1!

Capturing Standard Output/Error

The JUnit Platform provides opt-in support for capturing output printed to System.out and System.err. To enable it, set the junit.platform.output.capture.stdout and/or junit.platform.output.capture.stderr configuration parameter to true. In addition, you may configure the maximum number of buffered bytes to be used per executed test or container using junit.platform.output.capture.maxBuffer.

If enabled, the JUnit Platform captures the corresponding output and publishes it as a report entry using the stdout or stderr keys to all registered TestExecutionListener instances immediately before reporting the test or container as finished.

Please note that the captured output will only contain output emitted by the thread that was used to execute a container or test. Any output by other threads will be omitted because particularly when executing tests in parallel it would be impossible to attribute it to a specific test or container.