背景:
项目中包含了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>