步骤
在pom.xml中加入以下坐标即可导入starter-test的起步依赖,但如果使用IDEA中的SpringInitialize构建工程,内部就已经整合好了Junit测试的内容,不需要另外导入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
注意事项
如果测试类的软件包设置和主包一样,则不需要在@SpringBootTest注解中加入(classes = SpringBootJunitApplication.class)去指定对应测试的类,
但如果不一样则需要加上,否则会报错