当前位置:网站首页>Junit4运行mvn test 测试套件升级方案
Junit4运行mvn test 测试套件升级方案
2022-07-02 06:35:00 【别说小李】
背景:
项目中包含了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>
异常信息:
执行数量为0:[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
或者mvn -Dtest=TestSuiteOne test
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project wdseller-web: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]
解决方案:
- 第一种方案:全局升级到junit5
- 第二种方案:指定maven-surefire-plugin 到一个老的版本
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.19.1</version> <configuration> <includes> <include>com.wdtrip.seller.controller.TestSuiteOne</include> </includes> </configuration> </plugin>
其它:suit套件执行方法
- mvn -Dtest=TestSuiteOne test (通过指定测试suit,直接执行)
- 如上pom配置maven-surefire-plugin 的include后,直接执行mvn test ,效果相同
参考文档:
官方文档:Maven Surefire Plugin – Using JUnit
csdn:测试开发基础 mvn test | 利用 Maven Surefire Plugin 做测试用例基础执行管理 - 云+社区 - 腾讯云
Why Your JUnit 5 Tests Are Not Running Under Maven - Spring Framework Guru
边栏推荐
- Thinkphp5 how to determine whether a table exists
- Required request body is missing:(跨域问题)
- Mysql 多列IN操作
- In depth analysis of how the JVM executes Hello World
- C语言之数据插入
- Pool de connexion redis personnalisé
- 每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
- TD conducts functional simulation with Modelsim
- Mysql默认事务隔离级别及行锁
- vs+qt 设置应用程序图标
猜你喜欢
Image recognition - data augmentation
Required request body is missing:(跨域问题)
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
PI control of grid connected inverter (grid connected mode)
Pool de connexion redis personnalisé
Hystrix implements request consolidation
每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
PI control of three-phase grid connected inverter - off grid mode
三相并网逆变器PI控制——离网模式
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
随机推荐
Alibaba / popular JSON parsing open source project fastjson2
Alibaba /热门json解析开源项目 fastjson2
Error reporting on the first day of work (error reporting when Nessus installs WinPcap)
逆变器simulink模型——处理器在环测试(PIL)
2837xd 代碼生成——StateFlow(4)
Image recognition - data annotation
分布式锁的这三种实现方式,如何在效率和正确性之间选择?
BugkuCTF-web16(备份是个好习惯)
Bugkuctf-web16 (backup is a good habit)
定时线程池实现请求合并
The road is blocked and long, and the line is coming
ClassFile - Attributes - Code
因上努力,果上随缘
Attack and defense world web advanced area unserialize3
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
2837xd 代码生成——StateFlow(3)
Fragmenttabhost implements the interface of housing loan calculator
C语言之分草莓
图像识别-数据增广
Methods of classfile