AutoConfigureMockMvc+SpringBootTest自动注入MockMvc始终报找不到MockMvc bean,求指导

问题如图,自动注入MockMvc失败

问题如图,自动注入MockMvc失败
2018-04-24
这是我可以运行的文件,希望对你有帮助...
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"));
}
}举报