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.outSE および System.errSE の両方)がキャプチャーされた順序で返されます。 |
StringSE | getErr()System.errSE コンテンツをキャプチャーした順に返します。 |
StringSE | getOut()System.outSE コンテンツをキャプチャーした順に返します。 |
StringSE | toString() |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSEcharAt, length, subSequencecharsSE, codePointsSEpublic 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()
CapturedOutputSystem.outSE および System.errSE の両方)がキャプチャーされた順序で返されます。CapturedOutput 内の getAll public StringSE getOut()
CapturedOutputSystem.outSE コンテンツをキャプチャーした順に返します。CapturedOutput 内の getOut System.outSE キャプチャー出力 public StringSE getErr()
CapturedOutputSystem.errSE コンテンツをキャプチャーした順に返します。CapturedOutput 内の getErr System.errSE キャプチャー出力 public StringSE toString()
CharSequenceSE 内の toStringSE ObjectSE の toStringSE public void expect(org.hamcrest.Matcher<? super StringSE> matcher)
matcher と一致することを確認します。検証は、テストメソッドの実行後に実行されます。matcher - マッチャー