public interface ResultActions
See static factory methods in
HttpResultMatchers
HttpResultHandlers
HttpResultTransformers
| 限定符和类型 | 方法和说明 |
|---|---|
ResultActions |
andDo(ResultHandler handler)
Provide a general action.
|
ResultActions |
andExpect(ResultMatcher matcher)
Provide an expectation.
|
HttpResult |
andReturn()
Return the result of the executed request for direct access to the results.
|
<T> T |
andTransform(ResultTransform<T> transformer)
Provide a transformation of the result.
|
ResultActions andExpect(ResultMatcher matcher) throws Exception
static imports: MockMvcRequestBuilders.*, MockMvcResultMatchers.*
mockMvc.perform(get("/person/1"))
.andExpect(status().isOk())
.andExpect(content().mimeType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.person.name").equalTo("Jason"));
mockMvc.perform(post("/form"))
.andExpect(status().isOk())
.andExpect(redirectedUrl("/person/1"))
.andExpect(model().size(1))
.andExpect(model().attributeExists("person"))
.andExpect(flash().attributeCount(1))
.andExpect(flash().attribute("message", "success!"));
ExceptionResultActions andDo(ResultHandler handler) throws Exception
static imports: MockMvcRequestBuilders.*, MockMvcResultMatchers.*
mockMvc.perform(get("/form")).andDo(print());
Exception<T> T andTransform(ResultTransform<T> transformer) throws Exception
ExceptionHttpResult andReturn() throws Exception
ExceptionCopyright © 2016. All rights reserved.