課程
/后端開發
/Java
/Spring Boot進階之Web進階
老師您說:可以測試json,就好奇問問。如何編寫。
2017-08-06
源自:Spring Boot進階之Web進階 2-7
正在回答
有沒有好心人幫助看一下呀
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(); }
看了一下源碼,我試試,請老師,伙伴們回復下
HeroChan 提問者
舉報
《2小時學習Spring Boot》之進階教程,針對Web方面的相關技巧
4 回答單元測試,為什么輸入不正確還測試通過了?
2 回答向廖老師請教:測試girlList時總出現這樣錯誤
2 回答如何測試新增修改功能,怎么測試帶參數的方法
1 回答測試不通過,Actua的l結果不是數據庫結果集?
3 回答在Spring boot中如何實現session?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-08-06
有沒有好心人幫助看一下呀
2017-08-06
看了一下源碼,我試試,請老師,伙伴們回復下