Split up JUnit 5 OutputCapture class

Split the JUnit 5 `OutputCapture` class into separate `OutputExtension`
and `CapturedOutput` classes. The JUnit 5 callback methods are now
contained only in the `OutputExtension` class so no longer pollute the
public API that users will interact with.

The `CapturedOutput` class has also been updated to capture System.err
and System.out separately to allow distinct assertions if required.

Closes gh-17029
This commit is contained in:
Phillip Webb
2019-05-30 21:51:07 -07:00
parent 68a3fbd7a0
commit d11d5ceb29
49 changed files with 761 additions and 313 deletions

View File

@@ -20,7 +20,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.extension.OutputCapture;
import org.springframework.boot.test.extension.CapturedOutput;
import org.springframework.boot.test.extension.OutputExtension;
import static org.assertj.core.api.Assertions.assertThat;
@@ -30,12 +31,12 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
* @author Andy Wilkinson
*/
@ExtendWith(OutputCapture.class)
@ExtendWith(OutputExtension.class)
@SpringBootTest
class SampleMongoApplicationTests {
@Test
void testDefaultSettings(OutputCapture output) {
void testDefaultSettings(CapturedOutput output) {
assertThat(output).contains("firstName='Alice', lastName='Smith'");
}