Skip to content

Commit 8f8a4af

Browse files
Tetsuya3850philwebb
authored andcommitted
Document the pros and cons of MockMvc
Update the MockMvc documentation to provide more details about the pros and cons of such an approach, specifically calling out the difference with error page handling. See gh-16718
1 parent 827c624 commit 8f8a4af

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5639,6 +5639,12 @@ Alternatively, you can configure a {spring-framework-docs}testing.html#webtestcl
56395639
include::{code-examples}/test/web/MockWebTestClientExampleTests.java[tag=test-mock-web-test-client]
56405640
----
56415641

5642+
Testing within a mocked environment enables fast runs as it does not require the cost of setting up a full Servlet container.
5643+
Although this works fine in most cases, you cannot test situations where the servlet container takes precedence.
5644+
For example, Spring Boot's error handling is based on Servlet container’s error mappings.
5645+
Therefore, exceptions behave differently in the container-less mock environment than the real environment.
5646+
If you need to test the precise format of the error response, test with a fully running server as follows.
5647+
56425648

56435649

56445650
[[boot-features-testing-spring-boot-applications-testing-with-running-server]]

0 commit comments

Comments
 (0)