
导入junit依赖
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
在测试类后面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() {
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)