question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@AutoConfigureMockMvc shouldn't default to printing interactions by default

See original GitHub issue

Printing the output every interaction with the preconfigured MockMvc instances is not a good idea as it pollutes the output in test runs significantly, even if the test succeeds so that logs in CI runs get polluted by all that unnecessary output.

I can certainly see the appeal to default to print when developing test cases, but test cases are hopefully executed way more often in scenarios where nobody is even looking at the output (on the command line, in CI environments).

Of course the default can be tweaked easily bit it feels like there’ll be quite a lot of occasions where @WebMvcTest is used in combination with @AutoConfigureMockMvc(alwaysPrint = false) which sort of indicates that that would’ve been the better default.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
philwebbcommented, Jul 25, 2016

You can now disable printing for all tests by adding an application.properties in src/test/resources containing:

spring.test.mockmvc.print=none
1reaction
odrotbohmcommented, Jul 22, 2016

In know, I know. The thing is, that this then still pollutes the output and the stuff I might actually really want to see. I simply think that writing to Standard.out behind a user’s back has never been a good idea in the first place.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Boot integration test ignoring secure=false in ...
It says authentication is on, which I do not want. I've set it up with @AutoConfigureMockMvc(secure = false). I submit a mock request...
Read more >
Spring Boot Features
By default, INFO logging messages are shown, including some relevant startup details, such as the user that launched the application.
Read more >
Java Backend Testing - Broadleaf Dev Central
Because integration tests can take a very long time to run, unit tests should generally be your default choice when writing tests. Use...
Read more >
Spring Boot Reference Guide
Using the “default” Package . ... Switch off the Default MVC Configuration . ... Boot provides a way to analyze your application's environment...
Read more >
Spring Boot MockMVC Tutorial - Examples Java Code Geeks
Unit tests should not involve any external dependencies directly. ... @WebMvcTest auto-configures the MockMvc object by default.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found