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 charcharAt(int index) getAll()Return all content (bothSystem.outandSystem.err) in the order that it was captured.getErr()ReturnSystem.errcontent in the order that it was captured.getOut()ReturnSystem.outcontent in the order that it was captured.default intlength()default CharSequencesubSequence(int start, int end) Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty, toString
-
Method Details
-
length
default int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
default char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
getAll
String getAll()Return all content (bothSystem.outandSystem.err) in the order that it was captured.- Returns:
- all captured output
-
getOut
String getOut()ReturnSystem.outcontent in the order that it was captured.- Returns:
System.outcaptured output
-
getErr
String getErr()ReturnSystem.errcontent in the order that it was captured.- Returns:
System.errcaptured output
-