クラス OutputCaptureRule

java.lang.ObjectSE
org.springframework.boot.test.system.OutputCaptureRule
実装されたすべてのインターフェース:
CharSequenceSEorg.junit.rules.TestRuleCapturedOutput

public class OutputCaptureRule extends ObjectSE implements 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
  • コンストラクターの詳細

    • 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.TestRuleapply 
    • getAll

      public StringSE getAll()
      インターフェースからコピーされた説明: CapturedOutput
      すべてのコンテンツ(System.outSE および System.errSE の両方)がキャプチャーされた順序で返されます。
      次で指定:
      インターフェース CapturedOutputgetAll 
      戻り値:
      キャプチャーされたすべての出力
    • getOut

      public StringSE getOut()
      インターフェースからコピーされた説明: CapturedOutput
      System.outSE コンテンツをキャプチャーした順に返します。
      次で指定:
      インターフェース CapturedOutputgetOut 
      戻り値:
      System.outSE キャプチャー出力
    • getErr

      public StringSE getErr()
      インターフェースからコピーされた説明: CapturedOutput
      System.errSE コンテンツをキャプチャーした順に返します。
      次で指定:
      インターフェース CapturedOutputgetErr 
      戻り値:
      System.errSE キャプチャー出力
    • toString

      public StringSE toString()
      次で指定:
      インターフェース CharSequenceSEtoString 
      オーバーライド:
      クラス ObjectSEtoString 
    • expect

      public void expect(org.hamcrest.Matcher<? super StringSE> matcher)
      出力が提供された matcher と一致することを確認します。検証は、テストメソッドの実行後に実行されます。
      パラメーター:
      matcher - マッチャー