Skip to content

Add first class support for testing Spring MVC applications [SPR-9859] #14492

Closed
@spring-projects-issues

Description

@spring-projects-issues

Rossen Stoyanchev opened SPR-9859 and commented

This is based on the spring-test-mvc project that has been available on Github, as a separate project, for over a year. The project provides a fluent API for performing requests and verifying expectations on the resulting responses. It executes requests using an instance of DispatcherServlet and passes to it a MockHttpServletRequest and MockHttpServletResponse, i.e. without the need for a running a Servlet container.

WebApplicationContext wac = ...;

MockMvc mockMvc = webAppContextSetup(wac).configureWarRootDir("src/main/webapp", false).build()

mockMvc.perform(get("/form"))
    .andExpect(status().isOk())
    .andExpect(content().mimeType("text/html"))
    .andExpect(forwardedUrl("/WEB-INF/layouts/main.jsp"));

Affects: 3.1.2

Issue Links:

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions