当前位置:网站首页>Junit4 runs MVN test test suite upgrade scheme
Junit4 runs MVN test test suite upgrade scheme
2022-07-02 09:54:00 【Don't talk about Xiao Li】
background :
Included in the project junit4( Introduce... Independently ) and junit5(spring-boot-starter-parent 2.5.4 Bring your own version )
Currently we use springboot 3.5.4 Self contained maven-surefire-plugin Version is :2.22.2
The loading logic is as follows : According to junit5 Rule lookup test , But we suit The kit uses junit4 edition , Cause the unit test not found exception .
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>
Abnormal information :
Execution quantity is 0:[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
perhaps 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]
Solution :
- First option : Global upgrade to junit5
- Second option : Appoint maven-surefire-plugin To an old version
<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>Other :suit Suite execution method
- mvn -Dtest=TestSuiteOne test ( Pass the specified test suit, Direct execution )
- Above pom To configure maven-surefire-plugin Of include after , Direct execution mvn test , The effect is the same
Reference documents :
Official documents :Maven Surefire Plugin – Using JUnit
Why Your JUnit 5 Tests Are Not Running Under Maven - Spring Framework Guru

边栏推荐
猜你喜欢
随机推荐
在SQL注入中,为什么union联合查询,id必须等于0
2837xd code generation - stateflow (3)
How to handle error logic gracefully
Typora installation package sharing
PI control of grid connected inverter (grid connected mode)
2837xd代码生成模块学习(1)——GPIO模块
Idempotent design of Internet API interface
Int to string, int to qstring
Learn combinelatest through a practical example
JDBC回顾
Image recognition - data augmentation
XA Transaction SQL Statements
Operation and application of stack and queue
Bugkuctf-web21 (detailed problem solving ideas and steps)
Read Day6 30 minutes before going to bed every day_ Day6_ Date_ Calendar_ LocalDate_ TimeStamp_ LocalTime
BugkuCTF-web24(解题思路及步骤)
How to use pyqt5 to make a sensitive word detection tool
Navicat 远程连接Mysql报错1045 - Access denied for user ‘root‘@‘222.173.220.236‘ (using password: YES)
阿里云短信服务
渗透测试的介绍和防范








