public interface CapturedOutput extends CharSequence
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
OutputCaptureExtension| Modifier and Type | Method and Description |
|---|---|
default char |
charAt(int index) |
String |
getAll()
Return all content (both
System.out and System.err) in the order that it was captured. |
String |
getErr()
Return
System.err content in the order that it was captured. |
String |
getOut()
Return
System.out content in the order that it was captured. |
default int |
length() |
default CharSequence |
subSequence(int start,
int end) |
chars, codePoints, toStringdefault int length()
length in interface CharSequencedefault char charAt(int index)
charAt in interface CharSequencedefault CharSequence subSequence(int start, int end)
subSequence in interface CharSequenceString getAll()
System.out and System.err) in the order that it was captured.String getOut()
System.out content in the order that it was captured.System.out captured outputString getErr()
System.err content in the order that it was captured.System.err captured output