Polish 'Improve test coverage for OutputCaptureRule'

See gh-33405
This commit is contained in:
Phillip Webb 2022-11-29 14:09:26 -08:00
parent af7a03b4c9
commit 711e2528fb
1 changed files with 8 additions and 10 deletions

View File

@ -41,7 +41,6 @@ public class OutputCaptureRuleTests {
public void getAllShouldReturnAllCapturedOutput() {
System.out.println("Hello World");
System.err.println("Hello Error");
assertThat(this.output.getAll()).contains("Hello World", "Hello Error");
}
@ -49,23 +48,22 @@ public class OutputCaptureRuleTests {
public void getOutShouldOnlyReturnOutputCapturedFromSystemOut() {
System.out.println("Hello World");
System.err.println("Hello Error");
assertThat(this.output.getOut()).contains("Hello World");
assertThat(this.output.getOut()).doesNotContain("Hello Error");
}
@Test
public void getErrShouldOnlyReturnOutputCapturedFromSystemErr() {
System.out.println("Hello World");
System.err.println("Hello Error");
assertThat(this.output.getErr()).contains("Hello Error");
assertThat(this.output.getErr()).doesNotContain("Hello World");
}
@Test
public void captureShouldBeAssertable() {
System.out.println("Hello World");
assertThat(this.output).contains("Hello World");
}
@Test
public void getErrShouldOnlyReturnOutputCapturedFromSystemErr() {
System.out.println("Hello World");
System.err.println("Hello Error");
assertThat(this.output.getErr()).contains("Hello Error");
assertThat(this.output.getErr()).doesNotContain("Hello World");
}
}