2024-06-21 18:50:36 +08:00
|
|
|
[[mockmvc]]
|
|
|
|
= MockMvc
|
|
|
|
:page-section-summary-toc: 1
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2024-09-08 23:59:15 +08:00
|
|
|
MockMvc can be used on its own to perform requests and verify responses using Hamcrest or
|
|
|
|
through `MockMvcTester` which provides a fluent API using AssertJ. It can also be used
|
|
|
|
through the xref:testing/webtestclient.adoc[WebTestClient] where MockMvc is plugged in as
|
|
|
|
the server to handle requests. The advantage of using `WebTestClient` is that it provides
|
|
|
|
you the option of working 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.
|
2024-06-21 18:50:36 +08:00
|
|
|
|
|
|
|
|