Jan Galinski Jan Galinski - 2 months ago 19
Java Question

How to hide spring boot banner.txt in junit test with SpringJUnit4TestRunner?

When I configure an Spring Boot Application, I can disable the banner via run configuration in the static main method. So far so good.

But what if I have the following:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes={MyApplication.class})
public class MyApplicationTest {
....
}


When I run this test, it does not use the static main method and the banner is displayed, making it harder to focus on the relevant logging statements.

Is there a switch or config annotation I can use to simulate
new SpringApplication(MayApplicationclass).setShowBanner(false)...
?

Answer

You can put this in your test properties:

spring.main.show_banner=false
Comments