关于SpringBoot测试类无法运行问题
错误信息:Error running ‘DemoApplicationTests.contextLoads’: Failed to resolve org.junit.platform:junit-platform-launcher:1.6.3
Error running ‘DemoApplicationTests.contextLoads’: Failed to resolve org.junit.platform:junit-platform-launcher:1.6.3
这个错误信息其实已经表示测试没有找到这个jar包,而照成的报错!
照成这个报错的原因
上图的链接:上图网站链接
JUnti官网表示idea使用测试需要导入这三种jar包,而有一些版本的SpringBoot提供的test版本内缺少其中某些jar包,所以才会照成这种报错。
例如:我的工程使用的是springBoot 2.3.12.RELEASE版本,它的starter-test.jar包并没有包含org.junit.platform:junit-platform-launcher。
解决方案
在你使用测试的项目的pom文件下加入这个就可以愉快的运行了!
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>