2023-04-20 22:03:56 +08:00
|
|
|
[[test]]
|
2017-10-11 04:12:12 +08:00
|
|
|
= Testing
|
2023-04-19 23:26:17 +08:00
|
|
|
[.small]#xref:web-reactive.adoc#webflux-test[See equivalent in the Reactive stack]#
|
2017-10-11 04:12:12 +08:00
|
|
|
|
2018-02-07 01:16:31 +08:00
|
|
|
This section summarizes the options available in `spring-test` for Spring MVC applications.
|
2017-10-19 02:24:17 +08:00
|
|
|
|
2019-03-05 20:08:34 +08:00
|
|
|
* Servlet API Mocks: Mock implementations of Servlet API contracts for unit testing controllers,
|
2023-04-19 23:26:17 +08:00
|
|
|
filters, and other web components. See xref:testing/unit.adoc#mock-objects-servlet[Servlet API]
|
2019-03-05 20:08:34 +08:00
|
|
|
mock objects for more details.
|
2017-10-19 02:24:17 +08:00
|
|
|
|
2019-03-05 20:08:34 +08:00
|
|
|
* TestContext Framework: Support for loading Spring configuration in JUnit and TestNG tests,
|
|
|
|
including efficient caching of the loaded configuration across test methods and support for
|
|
|
|
loading a `WebApplicationContext` with a `MockServletContext`.
|
2023-04-19 23:26:17 +08:00
|
|
|
See xref:testing/testcontext-framework.adoc[TestContext Framework] for more details.
|
2017-10-11 04:12:12 +08:00
|
|
|
|
2019-03-05 20:08:34 +08:00
|
|
|
* Spring MVC Test: A framework, also known as `MockMvc`, for testing annotated controllers
|
|
|
|
through the `DispatcherServlet` (that is, supporting annotations), complete with the
|
|
|
|
Spring MVC infrastructure but without an HTTP server.
|
2023-04-19 23:26:17 +08:00
|
|
|
See xref:testing/spring-mvc-test-framework.adoc[Spring MVC Test] for more details.
|
2017-10-19 02:24:17 +08:00
|
|
|
|
2019-03-05 20:08:34 +08:00
|
|
|
* Client-side REST: `spring-test` provides a `MockRestServiceServer` that you can use as
|
|
|
|
a mock server for testing client-side code that internally uses the `RestTemplate`.
|
2023-04-19 23:26:17 +08:00
|
|
|
See xref:testing/spring-mvc-test-client.adoc[Client REST Tests] for more details.
|
2017-11-29 21:44:53 +08:00
|
|
|
|
2018-09-17 22:36:43 +08:00
|
|
|
* `WebTestClient`: Built for testing WebFlux applications, but it can also be used for
|
2018-02-07 01:16:31 +08:00
|
|
|
end-to-end integration testing, to any server, over an HTTP connection. It is a
|
2018-09-17 22:36:43 +08:00
|
|
|
non-blocking, reactive client and is well suited for testing asynchronous and streaming
|
2023-04-19 23:26:17 +08:00
|
|
|
scenarios. See xref:testing/webtestclient.adoc[`WebTestClient`] for more details.
|