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

When I configure the Spring boot application, I can disable the banner through the launch 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 a banner is displayed, which makes it difficult to focus on the corresponding logging statements.

Is there an annotation for the switch or configuration that I can use to model new SpringApplication(MayApplicationclass).setShowBanner(false)... ?

+5
source share
2 answers

You can put this in your test properties:

 spring.main.show_banner=false 
+8
source

Placing an empty banner.txt file in src / test / resources will stop displaying the banner during test execution.

+2
source

Source: https://habr.com/ru/post/1234855/


All Articles