标签:spring 自动装配 pre get请求 run 控制器 configure config orm
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc // 使用AutoConfigureMockMvc注解
public class GirlControllerTest {
@Autowired // 自动装配MockMvc
private MockMvc mockMvc;
@Test
public void girlList() throws Exception{
// 模拟get请求
mockMvc.perform(MockMvcRequestBuilders.get("/girls")).andExpect(MockMvcResultMatchers.status().is2xxSuccessful());
// mockMvc.perform(MockMvcRequestBuilders.get("/girls")).andExpect(MockMvcResultMatchers.content().string("hello world"))
}
}
标签:spring 自动装配 pre get请求 run 控制器 configure config orm
原文地址:https://www.cnblogs.com/vincenshen/p/10427888.html