HeroChan
2017-08-06 19:51
老师您说:可以测试json,就好奇问问。如何编写。
有没有好心人帮助看一下呀
public interface ResultActions {
/**
* Perform an expectation.
*
* <h4>Example</h4>
* <pre class="code">
* static imports: MockMvcRequestBuilders.*, MockMvcResultMatchers.*
*
* mockMvc.perform(get("/person/1"))
* .andExpect(status().isOk())
* .andExpect(content().contentType(MediaType.APPLICATION_JSON))
* .andExpect(jsonPath("$.person.name").value("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!"));
* </pre>
*/
ResultActions andExpect(ResultMatcher matcher) throws Exception;
/**
* Perform a general action.
*
* <h4>Example</h4>
* <pre class="code">
* static imports: MockMvcRequestBuilders.*, MockMvcResultMatchers.*
*
* mockMvc.perform(get("/form")).andDo(print());
* </pre>
*/
ResultActions andDo(ResultHandler handler) throws Exception;
/**
* Return the result of the executed request for direct access to the results.
*
* @return the result of the request
*/
MvcResult andReturn();
}看了一下源码,我试试,请老师,伙伴们回复下
Spring Boot进阶之Web进阶
104234 学习 · 425 问题
相似问题
回答 4