File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
spring-boot-project/spring-boot-test/src
main/java/org/springframework/boot/test/context
test/java/org/springframework/boot/test/context Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 2323
2424import org .springframework .beans .BeanUtils ;
2525import org .springframework .boot .ApplicationContextFactory ;
26+ import org .springframework .boot .Banner .Mode ;
2627import org .springframework .boot .DefaultPropertiesPropertySource ;
2728import org .springframework .boot .SpringApplication ;
2829import org .springframework .boot .WebApplicationType ;
@@ -129,6 +130,9 @@ else if (type == WebApplicationType.SERVLET) {
129130 }
130131 return ApplicationContextFactory .DEFAULT .create (type );
131132 });
133+ if (config .getParent () != null ) {
134+ application .setBannerMode (Mode .OFF );
135+ }
132136 application .setInitializers (initializers );
133137 boolean customEnvironent = ReflectionUtils .findMethod (getClass (), "getEnvironment" )
134138 .getDeclaringClass () != SpringBootContextLoader .class ;
Original file line number Diff line number Diff line change 1717package org .springframework .boot .test .context ;
1818
1919import org .junit .jupiter .api .Test ;
20+ import org .junit .jupiter .api .extension .ExtendWith ;
2021
2122import org .springframework .boot .test .context .SpringBootTestContextHierarchyTests .ChildConfiguration ;
2223import org .springframework .boot .test .context .SpringBootTestContextHierarchyTests .ParentConfiguration ;
24+ import org .springframework .boot .test .system .CapturedOutput ;
25+ import org .springframework .boot .test .system .OutputCaptureExtension ;
2326import org .springframework .context .annotation .Bean ;
2427import org .springframework .context .annotation .Configuration ;
2528import org .springframework .test .context .ContextConfiguration ;
2629import org .springframework .test .context .ContextHierarchy ;
2730
31+ import static org .assertj .core .api .Assertions .assertThat ;
32+
2833/**
2934 * Tests for {@link SpringBootTest @SpringBootTest} and
3035 * {@link ContextHierarchy @ContextHierarchy}.
3439@ SpringBootTest
3540@ ContextHierarchy ({ @ ContextConfiguration (classes = ParentConfiguration .class ),
3641 @ ContextConfiguration (classes = ChildConfiguration .class ) })
42+ @ ExtendWith (OutputCaptureExtension .class )
3743class SpringBootTestContextHierarchyTests {
3844
3945 @ Test
40- void contextLoads () {
41-
46+ void contextLoads (CapturedOutput capturedOutput ) {
47+ assertThat ( capturedOutput ). containsOnlyOnce ( ":: Spring Boot ::" );
4248 }
4349
4450 @ Configuration (proxyBeanMethods = false )
You can’t perform that action at this time.
0 commit comments