The_Spring MVC Test framework_provides first class support for testing Spring MVC code using a fluent API that can be used with JUnit, TestNG, or any other testing framework. It’s built on theServlet API mock objectsfrom thespring-test
module and hence does_not_use a running Servlet container. It uses theDispatcherServlet
to provide full Spring MVC runtime behavior and provides support for loading actual Spring configuration with the_TestContext framework_in addition to a standalone mode in which controllers may be instantiated manually and tested one at a time.
_Spring MVC Test_also provides client-side support for testing code that uses theRestTemplate
. Client-side tests mock the server responses and also do_not_use a running server.
Spring Boot provides an option to write full, end-to-end integration tests that include a running server. If this is your goal please have a look at theSpring Boot reference page. For more information on the differences between out-of-container and end-to-end integration tests, seethe section called “Differences between Out-of-Container and End-to-End Integration Tests”. |