public class OutputCaptureRule extends ObjectSE implements org.junit.rules.TestRule, CapturedOutput
@Rule
。add を @Rule
として使用するには:
public class MyTest { @Rule public OutputCaptureRule output = new OutputCaptureRule(); @Test public void test() { assertThat(output).contains("ok"); } }
コンストラクターと説明 |
---|
OutputCaptureRule() |
修飾子と型 | メソッドと説明 |
---|---|
org.junit.runners.model.Statement | apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) |
void | expect(org.hamcrest.Matcher<? super StringSE> matcher) 出力が提供された matcher と一致することを確認します。 |
StringSE | getAll() すべてのコンテンツ( System.out SE および System.err SE の両方)がキャプチャーされた順序で返されます。 |
StringSE | getErr() System.err SE コンテンツをキャプチャーした順に返します。 |
StringSE | getOut() System.out SE コンテンツをキャプチャーした順に返します。 |
StringSE | toString() |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
charAt, length, subSequence
charsSE, codePointsSE
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
org.junit.rules.TestRule
の apply
public StringSE getAll()
CapturedOutput
System.out
SE および System.err
SE の両方)がキャプチャーされた順序で返されます。CapturedOutput
の getAll
public StringSE getOut()
CapturedOutput
System.out
SE コンテンツをキャプチャーした順に返します。CapturedOutput
の getOut
System.out
SE キャプチャー出力 public StringSE getErr()
CapturedOutput
System.err
SE コンテンツをキャプチャーした順に返します。CapturedOutput
の getErr
System.err
SE キャプチャー出力 public StringSE toString()
CharSequenceSE
の toStringSE
ObjectSE
の toStringSE
public void expect(org.hamcrest.Matcher<? super StringSE> matcher)
matcher
と一致することを確認します。検証は、テストメソッドの実行後に実行されます。matcher
- マッチャー