課程
/后端開發(fā)
/Java
/Spring Boot進(jìn)階之Web進(jìn)階
問(wèn)題如圖,自動(dòng)注入MockMvc失敗
2018-04-24
源自:Spring Boot進(jìn)階之Web進(jìn)階 2-7
正在回答
這是我可以運(yùn)行的文件,希望對(duì)你有幫助...
package?com.chengsluo.demo.controller; import?org.junit.Test; import?org.junit.runner.RunWith; import?org.springframework.beans.factory.annotation.Autowired; import?org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import?org.springframework.boot.test.context.SpringBootTest; import?org.springframework.test.context.junit4.SpringRunner; import?org.springframework.test.web.servlet.MockMvc; import?org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import?org.springframework.test.web.servlet.result.MockMvcResultMatchers; @RunWith(SpringRunner.class) @SpringBootTest @AutoConfigureMockMvc public?class?GrilControllerTest?{ ???@Autowired ???private?MockMvc?mockMvc; ???@Test ???public?void?girlsList()?throws?Exception?{ ??????mockMvc.perform(MockMvcRequestBuilders.get("/girls")) ????????????.andExpect(MockMvcResultMatchers.status().isOk()); //??????????.andExpect(MockMvcResultMatchers.status().string("213")); ???} }
qq_流浪_1 提問(wèn)者
非洲白白 回復(fù) qq_流浪_1 提問(wèn)者
舉報(bào)
《2小時(shí)學(xué)習(xí)Spring Boot》之進(jìn)階教程,針對(duì)Web方面的相關(guān)技巧
3 回答MockMvc報(bào)錯(cuò)是為什么
2 回答單元測(cè)試時(shí)報(bào)錯(cuò),求指導(dǎo)
1 回答映射不到方法,求指教
1 回答關(guān)于接受參數(shù)的Bean和數(shù)據(jù)入庫(kù)的Bean,是否不應(yīng)該是同一個(gè)Bean?
2 回答找不到2小時(shí)學(xué)會(huì)的入門課
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2018-04-25
這是我可以運(yùn)行的文件,希望對(duì)你有幫助...