Interface CapturedOutput
- All Superinterfaces:
CharSequence
- All Known Implementing Classes:
OutputCaptureRule
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
- Since:
- 2.2.0
- Author:
- Madhura Bhave, Phillip Webb, Andy Wilkinson
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault char
charAt
(int index) getAll()
Return all content (bothSystem.out
andSystem.err
) in the order that it was captured.getErr()
ReturnSystem.err
content in the order that it was captured.getOut()
ReturnSystem.out
content in the order that it was captured.default int
length()
default CharSequence
subSequence
(int start, int end) Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty, toString
-
Method Details
-
length
default int length()- Specified by:
length
in interfaceCharSequence
-
charAt
default char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
getAll
String getAll()Return all content (bothSystem.out
andSystem.err
) in the order that it was captured.- Returns:
- all captured output
-
getOut
String getOut()ReturnSystem.out
content in the order that it was captured.- Returns:
System.out
captured output
-
getErr
String getErr()ReturnSystem.err
content in the order that it was captured.- Returns:
System.err
captured output
-