对Service的Test
pom.xml引入junit
加注解:
@RunWith(SpringRunner.class)
@SpringBootTest
@Test
对Controller的Test
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
@Test
@RunWith(SpringRunner.class) @SpringBootTest @AutoConfigureMockMvc public class GrilController { @Autowired private MockMvc mvc; @Test public void girlList() throws Exception { mvc.perform( MockMvcRequestBuilders.get("/girl/girls")) .andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.content().string("abc")); } }
批量 / 跳过单元测试