Spring Boot 整合 Junit 单元测试
SpringBoot2.x 使用 Junit5 作为测试平台
修改 POM 文件添加 Test 启动器
一般用官网创建或者是IDEA工具创建的都自带了
注意一下如果配置了这个,就不能用5一下的junit了
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<!--junit-vintage-engine 提供了 Junit3 与 Junit4 的运行平台-->
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
测试代码
加两个注解就可以进行测试了