今天整合单元测试的时候出现了一个问题
然后我查看依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<!-- <scope>test</scope>-->
</dependency>
注释掉scope解决了@SpringBoot报错的问题
但奇怪的是SpringRunner系统找不到,于是我根据网上的教程发现是我的依赖导错了,需要的不是spring-boot-test而是spring-boot-starter-test
所以我更换了依赖并且将junit的版本更新到最新
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<!-- <scope>test</scope>-->
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>compile</scope>
</dependency>
问题解决