类 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.Statement
apply
(org.junit.runners.model.Statement base, org.junit.runner.Description description) void
Verify that the output is matched by the suppliedmatcher
.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.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
从接口复制的说明:CapturedOutput
Return all content (bothSystem.out
andSystem.err
) in the order that it was captured.- 指定者:
getAll
在接口中CapturedOutput
- 返回:
- all captured output
-
getOut
从接口复制的说明:CapturedOutput
ReturnSystem.out
content in the order that it was captured.- 指定者:
getOut
在接口中CapturedOutput
- 返回:
System.out
captured output
-
getErr
从接口复制的说明:CapturedOutput
ReturnSystem.err
content in the order that it was captured.- 指定者:
getErr
在接口中CapturedOutput
- 返回:
System.err
captured 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
-