标签:contex ram nes print follow expect @class 需要 exce
package com.springboot.demo.controller;@Version 1.0br/>**/
@RunWith(SpringRunner.class)
@SpringBootTest
public class LeaveControllerTest {
private MockMvc mockMvc;
@Before
public void setUp() throws Exception{
mockMvc = MockMvcBuilders.standaloneSetup(new LeaveController()).build();
}
@Test
public void hello() throws Exception{
mockMvc.perform(MockMvcRequestBuilders.get("/level/hello").accept(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcResultHandlers.print())
.andReturn();
}
}
说明:
new LeaveController()表示需要测试的控制器类
MockMvcRequestBuilders.get("/level/hello"):请求的方法
标签:contex ram nes print follow expect @class 需要 exce
原文地址:https://blog.51cto.com/suyanzhu/2389770