> For the complete documentation index, see [llms.txt](https://docs.flydean.com/spring-framework-documentation5/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flydean.com/spring-framework-documentation5/webservlet/3.testing.md).

# 3. 测试

本节总结了Spring MVC应用程序在spring-test中可用的选项。

* Servlet API模拟：用于单元测试控制器，过滤器和其他Web组件的Servlet API合约的模拟实现。有关更多详细信息，请参见Servlet API模拟对象。
* TestContext Framework：支持在JUnit和TestNG测试中加载Spring配置，包括跨测试方法高效地缓存已加载的配置，并支持通过MockServletContext加载WebApplicationContext。有关更多详细信息，请参见TestContext Framework。
* Spring MVC测试：一种框架，也称为MockMvc，用于通过DispatcherServlet（即支持注解）测试带注解的控制器，该框架具有Spring MVC基础结构，但没有HTTP服务器。有关更多详细信息，请参见Spring MVC Test。
* 客户端REST：spring-test提供了一个MockRestServiceServer，您可以将其用作模拟服务器，以测试内部使用RestTemplate的客户端代码。有关更多详细信息，请参见客户端REST测试。
* WebTestClient：构建用于测试WebFlux应用程序，但是它也可以用于通过HTTP连接到任何服务器的端到端集成测试。它是一个无阻塞的反应式客户端，非常适合测试异步和流传输方案。
