public interface ResultActions
See static factory methods in
MockMvcResultMatchers
and
MockMvcResultHandlers
.
Modifier and Type | Method and Description |
---|---|
ResultActions |
andDo(ResultHandler handler)
Perform a general action.
|
ResultActions |
andExpect(ResultMatcher matcher)
Perform an expectation.
|
MvcResult |
andReturn()
Return the result of the executed request for direct access to the results.
|
ResultActions andExpect(ResultMatcher matcher) throws java.lang.Exception
static imports: MockMvcRequestBuilders.*, MockMvcResultMatchers.* mockMvc.perform(get("/person/1")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.person.name").value("Jason"));
Or alternatively provide all matchers as a vararg:
static imports: MockMvcRequestBuilders.*, MockMvcResultMatchers.*, ResultMatcher.matchAll mockMvc.perform(post("/form")) .andExpect(matchAll( status().isOk(), redirectedUrl("/person/1"), model().size(1), model().attributeExists("person"), flash().attributeCount(1), flash().attribute("message", "success!")) );
java.lang.Exception
ResultActions andDo(ResultHandler handler) throws java.lang.Exception
static imports: MockMvcRequestBuilders.*, MockMvcResultMatchers.* mockMvc.perform(get("/form")).andDo(print());
java.lang.Exception
MvcResult andReturn()