2022-11-19 00:33:40 +08:00
|
|
|
[[spring-mvc-test-framework]]
|
|
|
|
= MockMvc
|
2023-04-19 23:26:17 +08:00
|
|
|
:page-section-summary-toc: 1
|
2022-11-19 00:33:40 +08:00
|
|
|
|
|
|
|
The Spring MVC Test framework, also known as MockMvc, provides support for testing Spring
|
|
|
|
MVC applications. It performs full Spring MVC request handling but via mock request and
|
|
|
|
response objects instead of a running server.
|
|
|
|
|
|
|
|
MockMvc can be used on its own to perform requests and verify responses. It can also be
|
2023-04-19 23:26:17 +08:00
|
|
|
used through the xref:testing/webtestclient.adoc[WebTestClient] where MockMvc is plugged in as the server to handle
|
2022-11-19 00:33:40 +08:00
|
|
|
requests with. The advantage of `WebTestClient` is the option to work with higher level
|
|
|
|
objects instead of raw data as well as the ability to switch to full, end-to-end HTTP
|
|
|
|
tests against a live server and use the same test API.
|
|
|
|
|
|
|
|
|