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