Commit 8f8a4af0 authored by Tetsuya Hasegawa's avatar Tetsuya Hasegawa Committed by Phillip Webb

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
parent 827c624b
...@@ -5639,6 +5639,12 @@ Alternatively, you can configure a {spring-framework-docs}testing.html#webtestcl ...@@ -5639,6 +5639,12 @@ Alternatively, you can configure a {spring-framework-docs}testing.html#webtestcl
include::{code-examples}/test/web/MockWebTestClientExampleTests.java[tag=test-mock-web-test-client] include::{code-examples}/test/web/MockWebTestClientExampleTests.java[tag=test-mock-web-test-client]
---- ----
Testing within a mocked environment enables fast runs as it does not require the cost of setting up a full Servlet container.
Although this works fine in most cases, you cannot test situations where the servlet container takes precedence.
For example, Spring Boot's error handling is based on Servlet container’s error mappings.
Therefore, exceptions behave differently in the container-less mock environment than the real environment.
If you need to test the precise format of the error response, test with a fully running server as follows.
[[boot-features-testing-spring-boot-applications-testing-with-running-server]] [[boot-features-testing-spring-boot-applications-testing-with-running-server]]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment