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 コンテンツをキャプチャーした順に返します。 |
void | reset() 使用すべきではありません。 2.2.0 以降、代替なし |
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 @DeprecatedSE public void reset()
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 - マッチャー Copyright © 2020 Pivotal Software, Inc.. All rights reserved.