# 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连接到任何服务器的端到端集成测试。它是一个无阻塞的反应式客户端，非常适合测试异步和流传输方案。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flydean.com/spring-framework-documentation5/webservlet/3.testing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
