背景:
项目中包含了junit4(独立引入) 和junit5(spring-boot-starter-parent 2.5.4自带版本)
目前我们使用的springboot 3.5.4自带的maven-surefire-plugin 版本为:2.22.2
其加载逻辑如下: 会按照junit5的规则查找测试,但是我们suit套件使用的是junit4版本,导致出现找不到单元测试异常。
if the JUnit 5 Platform Engine is present in the project
use junit-platform
if the JUnit version in the project >= 4.7 and the <<<parallel>>> configuration parameter has ANY value
use junit47 provider
if JUnit >= 4.0 is present
use junit4 provider
else
use junit3.8.1
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>

项目中同时存在Junit4和Junit5,Spring Boot 2.5.4自带maven-surefire-plugin版本导致Junit4测试套件无法执行。解决方案包括全局升级到Junit5或回退maven插件版本。通过`mvn -Dtest=TestSuiteOne test`可指定测试套件执行。
最低0.47元/天 解锁文章
1088

被折叠的 条评论
为什么被折叠?



