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:
Phillip Webb
2019-07-14 19:10:02 +01:00
parent 79b29396d0
commit 8d4a2add63
3 changed files with 57 additions and 4 deletions

View File

@@ -34,7 +34,7 @@ import static org.hamcrest.Matchers.allOf;
* @author Andy Wilkinson
* @since 2.2.0
*/
public class OutputCaptureRule implements TestRule {
public class OutputCaptureRule implements TestRule, CapturedOutput {
private final OutputCapture delegate = new OutputCapture();
@@ -64,6 +64,21 @@ public class OutputCaptureRule implements TestRule {
};
}
@Override
public String getAll() {
return this.delegate.getAll();
}
@Override
public String getOut() {
return this.delegate.getOut();
}
@Override
public String getErr() {
return this.delegate.getErr();
}
@Override
public String toString() {
return this.delegate.toString();