Allow OutputCaptureRule to be used with AssertJ
Update `OutputCaptureRule` so that it now implements `CapturedOutput` and can be used directly with AssertJ. Closes gh-17512
This commit is contained in:
@@ -29,12 +29,18 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class OutputCaptureRuleTests {
|
||||
|
||||
@Rule
|
||||
public OutputCaptureRule outputCapture = new OutputCaptureRule();
|
||||
public OutputCaptureRule output = new OutputCaptureRule();
|
||||
|
||||
@Test
|
||||
public void toStringShouldReturnAllCapturedOutput() {
|
||||
System.out.println("Hello World");
|
||||
assertThat(this.outputCapture.toString()).contains("Hello World");
|
||||
assertThat(this.output.toString()).contains("Hello World");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void captureShouldBeAssertable() {
|
||||
System.out.println("Hello World");
|
||||
assertThat(this.output).contains("Hello World");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user