Refine SpringBootTest.useMainMethod support

Refine `SpringBootContextLoader` so that calls to the main method do
not exit early and the hook is only used when necessary.

See gh-22405
This commit is contained in:
Phillip Webb
2022-09-15 10:10:02 -07:00
parent f1b60eef55
commit 48f3cd75d4
3 changed files with 37 additions and 24 deletions

View File

@@ -20,6 +20,7 @@ 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.context.SpringBootTest.UseMainMethod;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
@@ -31,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
*/
@ExtendWith(OutputCaptureExtension.class)
@SpringBootTest
@SpringBootTest(useMainMethod = UseMainMethod.NEVER)
class SampleLdapApplicationTests {
@Test