Repackage output capture and always use extension declaratively
Closes gh-17029
This commit is contained in:
@@ -17,11 +17,11 @@
|
||||
package sample.data.neo4j;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.neo4j.driver.v1.exceptions.ServiceUnavailableException;
|
||||
|
||||
import org.springframework.boot.test.extension.CapturedOutput;
|
||||
import org.springframework.boot.test.extension.OutputExtension;
|
||||
import org.springframework.boot.test.system.CapturedOutput;
|
||||
import org.springframework.boot.test.system.OutputCaptureExtension;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -30,13 +30,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ExtendWith(OutputCaptureExtension.class)
|
||||
class SampleNeo4jApplicationTests {
|
||||
|
||||
@RegisterExtension
|
||||
CapturedOutput output = OutputExtension.capture();
|
||||
|
||||
@Test
|
||||
void testDefaultSettings() {
|
||||
void testDefaultSettings(CapturedOutput capturedOutput) {
|
||||
try {
|
||||
SampleNeo4jApplication.main(new String[0]);
|
||||
}
|
||||
@@ -45,7 +43,7 @@ class SampleNeo4jApplicationTests {
|
||||
return;
|
||||
}
|
||||
}
|
||||
assertThat(this.output).contains("firstName='Alice', lastName='Smith'");
|
||||
assertThat(capturedOutput).contains("firstName='Alice', lastName='Smith'");
|
||||
}
|
||||
|
||||
private boolean neo4jServerRunning(Throwable ex) {
|
||||
|
||||
Reference in New Issue
Block a user