Class OutputCaptureRule
java.lang.Object
org.springframework.boot.test.system.OutputCaptureRule
- All Implemented Interfaces:
- CharSequence,- org.junit.rules.TestRule,- CapturedOutput
JUnit 
@Rule to capture output from System.out and System.err.
 
 To use add as a @Rule:
 
 public class MyTest {
     @Rule
     public OutputCaptureRule output = new OutputCaptureRule();
     @Test
     public void test() {
         assertThat(output).contains("ok");
     }
 }
 - Since:
- 2.2.0
- Author:
- Phillip Webb, Andy Wilkinson
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionorg.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description) voidVerify that the output is matched by the suppliedmatcher.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.toString()Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.boot.test.system.CapturedOutputcharAt, length, subSequenceMethods inherited from interface java.lang.CharSequencechars, codePoints, isEmpty
- 
Constructor Details- 
OutputCaptureRulepublic OutputCaptureRule()
 
- 
- 
Method Details- 
applypublic org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) - Specified by:
- applyin interface- org.junit.rules.TestRule
 
- 
getAllDescription copied from interface:CapturedOutputReturn all content (bothSystem.outandSystem.err) in the order that it was captured.- Specified by:
- getAllin interface- CapturedOutput
- Returns:
- all captured output
 
- 
getOutDescription copied from interface:CapturedOutputReturnSystem.outcontent in the order that it was captured.- Specified by:
- getOutin interface- CapturedOutput
- Returns:
- System.outcaptured output
 
- 
getErrDescription copied from interface:CapturedOutputReturnSystem.errcontent in the order that it was captured.- Specified by:
- getErrin interface- CapturedOutput
- Returns:
- System.errcaptured output
 
- 
toString- Specified by:
- toStringin interface- CharSequence
- Overrides:
- toStringin class- Object
 
- 
expectVerify that the output is matched by the suppliedmatcher. Verification is performed after the test method has executed.- Parameters:
- matcher- the matcher
 
 
-