导入junit依赖
junit junit test org.springframework.boot spring-boot-starter-test
在测试类后面alt+ins
选择Junit4和要Test的类
添加注解(classes中要写启动类名字)
@RunWith(SpringRunner.class) @SpringBootTest(classes = ApiApplication.class)
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplication.class)
public class UserServiceTest {
@Autowired
private UserService userService;
@Test
public void userRegist() {
}
}



