类 OutputCaptureRule
java.lang.Object
org.springframework.boot.test.system.OutputCaptureRule
- 所有已实现的接口:
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");
}
}
- 从以下版本开始:
- 2.2.0
- 作者:
- Phillip Webb, Andy Wilkinson
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明org.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()从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait从接口继承的方法 org.springframework.boot.test.system.CapturedOutput
charAt, length, subSequence从接口继承的方法 java.lang.CharSequence
chars, codePoints, isEmpty
-
构造器详细资料
-
OutputCaptureRule
public OutputCaptureRule()
-
-
方法详细资料
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) - 指定者:
apply在接口中org.junit.rules.TestRule
-
getAll
从接口复制的说明:CapturedOutputReturn all content (bothSystem.outandSystem.err) in the order that it was captured.- 指定者:
getAll在接口中CapturedOutput- 返回:
- all captured output
-
getOut
从接口复制的说明:CapturedOutputReturnSystem.outcontent in the order that it was captured.- 指定者:
getOut在接口中CapturedOutput- 返回:
System.outcaptured output
-
getErr
从接口复制的说明:CapturedOutputReturnSystem.errcontent in the order that it was captured.- 指定者:
getErr在接口中CapturedOutput- 返回:
System.errcaptured output
-
toString
- 指定者:
toString在接口中CharSequence- 覆盖:
toString在类中Object
-
expect
Verify that the output is matched by the suppliedmatcher. Verification is performed after the test method has executed.- 参数:
matcher- the matcher
-