クラス OutputCaptureRule
java.lang.ObjectSE
org.springframework.boot.test.system.OutputCaptureRule
- 実装済みのインターフェース一覧:
CharSequenceSE、org.junit.rules.TestRule、CapturedOutput
System.out および System.err からの出力をキャプチャーするための JUnit @Rule。add を @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) void出力が提供されたmatcherと一致することを確認します。getAll()すべてのコンテンツ(System.outSE およびSystem.errSE の両方)がキャプチャーされた順序で返されます。getErr()System.errSE コンテンツをキャプチャーした順に返します。getOut()System.outSE コンテンツをキャプチャーした順に返します。toString()クラス java.lang.ObjectSE から継承されたメソッド
clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, wait, waitSE, waitSEインターフェース org.springframework.boot.test.system.CapturedOutput から継承されたメソッド
charAt, length, subSequenceインターフェース java.lang.CharSequenceSE から継承されたメソッド
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) - 次で指定:
- インターフェース
org.junit.rules.TestRule内のapply
getAll
インターフェースからコピーされた説明:CapturedOutputすべてのコンテンツ(System.outSE およびSystem.errSE の両方)がキャプチャーされた順序で返されます。- 次で指定:
- インターフェース
CapturedOutput内のgetAll - 戻り値:
- キャプチャーされたすべての出力
getOut
インターフェースからコピーされた説明:CapturedOutputSystem.outSE コンテンツをキャプチャーした順に返します。- 次で指定:
- インターフェース
CapturedOutput内のgetOut - 戻り値:
System.outSE キャプチャー出力
getErr
インターフェースからコピーされた説明:CapturedOutputSystem.errSE コンテンツをキャプチャーした順に返します。- 次で指定:
- インターフェース
CapturedOutput内のgetErr - 戻り値:
System.errSE キャプチャー出力
toString
- 次で指定:
- インターフェース
CharSequenceSE内のtoString - オーバーライド:
- クラス
ObjectSEのtoString
expect
出力が提供されたmatcherと一致することを確認します。検証は、テストメソッドの実行後に実行されます。- パラメーター:
matcher- マッチャー