OutputCaptureRule
JUnit @Rule
to capture output from System.out
and System.err
.
To use add as a @Rule:
public class MyTest {
@Rule
public OutputCaptureRule output = new OutputCaptureRule();
@Test
public void test() {
assertThat(output).contains("ok");
}
}
Content copied to clipboard
Author
Phillip Webb
Andy Wilkinson
Since
2.2.0
Functions
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Return all content (both System.out and System.err) in the order that it was captured.
Link copied to clipboard
Return System.err content in the order that it was captured.
Link copied to clipboard
Return System.out content in the order that it was captured.
Link copied to clipboard