CapturedOutput

Provides access to System.out and System.err output that has been captured by the OutputCaptureExtension or OutputCaptureRule. Can be used to apply assertions either using AssertJ or standard JUnit assertions. For example:

assertThat(output).contains("started"); // Checks all output
assertThat(output.getErr()).contains("failed"); // Only checks System.err
assertThat(output.getOut()).contains("ok"); // Only checks System.out

Author

Madhura Bhave

Phillip Webb

Andy Wilkinson

Since

2.2.0

See also

Inheritors

Functions

Link copied to clipboard
open fun charAt(index: Int): Char
Link copied to clipboard
open fun chars(): IntStream
Link copied to clipboard
open fun codePoints(): IntStream
Link copied to clipboard
open fun compare(cs1: CharSequence, cs2: CharSequence): Int
Link copied to clipboard
abstract fun getAll(): String
Return all content (both System.out and System.err) in the order that it was captured.
Link copied to clipboard
abstract fun getErr(): String
Return System.err content in the order that it was captured.
Link copied to clipboard
abstract fun getOut(): String
Return System.out content in the order that it was captured.
Link copied to clipboard
open fun isEmpty(): Boolean
Link copied to clipboard
open fun length(): Int
Link copied to clipboard
open fun subSequence(start: Int, end: Int): CharSequence
Link copied to clipboard
abstract fun toString(): String