mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge pull request #33405 from currenjin
* pr/33405: Polish 'Improve test coverage for OutputCaptureRule' Improve test coverage for OutputCaptureRule Closes gh-33405
This commit is contained in:
commit
e56156c350
@ -37,6 +37,29 @@ public class OutputCaptureRuleTests {
|
||||
assertThat(this.output.toString()).contains("Hello World");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllShouldReturnAllCapturedOutput() {
|
||||
System.out.println("Hello World");
|
||||
System.err.println("Hello Error");
|
||||
assertThat(this.output.getAll()).contains("Hello World", "Hello Error");
|
||||
}
|
||||
|
||||
@Test
|
||||
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");
|
||||
|
Loading…
Reference in New Issue
Block a user