spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Default SpringBootTest to "spring.main.banner-mode=off"

Open codefromthecrypt opened this issue 1 year ago • 1 comments

Right now, tests driven by @SpringBootTest whirr up an application and a side effect is the spring boot logo in the logs. This isn't so much a problem the first time, but if you write a lot of tests, you'll quickly drown your console or CI logs with the logo. Let's default it to "spring.main.banner-mode=off", or if it is quite important to show the logo, some how rate limit it to once per run!

codefromthecrypt avatar Feb 15 '24 07:02 codefromthecrypt

I deactivate the banner for my test profile in the configuration.

yep while every project can do this, the request is about if this can be made default, so we don't have to. Currently, I also do this, but sometimes I work on other projects who don't and see tons of banners fly by which hide higher value lines.

codefromthecrypt avatar Feb 16 '24 11:02 codefromthecrypt

@SpringBootTest is not enough, test slices like @JdbcTest should adapt also.

quaff avatar Feb 18 '24 08:02 quaff

Actually from security perspective, it is better for spring boot to autoconfigure to set the banner to off. not just for testing portion.

Cos if u execute the spring boot application via console, the console will start printing out the spring boot logo and its info. Anyone walking behind u, will see these info. From security perspective, it is best to avoid letting external people know as much information about your application (including the framework used).

hannah23280 avatar Feb 19 '24 09:02 hannah23280

We discussed this today as a team and we're not keen to change the default banner display. We feel it's better for @SpringBootTest to work as closely as possible to the real application. We've also found that the banner helps folks to understand application context caching in tests.

We do think that it would be nice if folks could disable the banner easily if they want to, but we think that #38098 will provide a good way to do that when it's implemented.

In the meantime, you might be able to add an empty banner.txt file to src/test/resources or consider tuning your build system so that console output is redirected to file. Gradle does this by default and it gives you clean console output but still access to the logs when reviewing the test report.

philwebb avatar Feb 22 '24 16:02 philwebb

thanks, empty banner was the trick we didn't think about. cheers! https://github.com/openzipkin/zipkin/pull/3734

codefromthecrypt avatar Feb 23 '24 00:02 codefromthecrypt