Skip to content

Commit da1d7cf

Browse files
committed
Merge pull request #16718 from Tetsuya3850
* pr/16718: Polish "Document the pros and cons of MockMvc" Document the pros and cons of MockMvc Closes gh-16718
2 parents 827c624 + 624c118 commit da1d7cf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5639,6 +5639,16 @@ 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+
[TIP]
5643+
====
5644+
Testing within a mocked environment is usually faster than running with a full Servlet container.
5645+
However, since mocking occurs at the Spring MVC layer, code that relies on on lower level Servlet concerns cannot be directly tested with MockMvc.
5646+
5647+
For example, Spring Boot's error handling is based on the "`error page`" support provided by the Servlet container.
5648+
This means that, whilst you can test your MVC layer throws and handles exceptions as expected, you cannot directly test that a specific <<#boot-features-error-handling-custom-error-pages, custom error page>> is rendered.
5649+
If you need to tests these lower-level concerns, you can start a fully running server as described in the next section.
5650+
====
5651+
56425652

56435653

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

0 commit comments

Comments
 (0)