当前位置:网站首页>Junit5 支持suite的方法
Junit5 支持suite的方法
2022-07-02 06:35:00 【别说小李】
背景:
单元测试中有部分是不希望自动执行的,仅有部分单元测试希望在内网http://10.0.0.65/ 服务器上自动运行,因此希望配置suite 以解决部分执行问题。
(junit5 低版本中没有suite,目前我们springboot默认带的junit5 需要升级)
带来的好处:
- mvn test 仅执行部分核心的选中单元测试
- 单元测试可分组管理
- 进行测试间的编排顺序
方法:
1. 在web 应用中引入junit5
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.8.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>2. 引入suite的包
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-engine</artifactId>
</dependency>3. 代码使用suite
package com.wdtrip.wdpromotion;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;
@Suite
@SelectClasses({TestCustomPage.class,
TestEbkActivity.class
})
public class TestSuiteOne {
}
4. 在pom文件的build中配置需要执行的suite
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>com.wdtrip.wdpromotion.TestSuiteOne</include>
</includes>
</configuration>
</plugin>junit5 单元测试顺序编排方式
按照方法名称:MethodOrderer.MethodName.class
按照自己注解的顺序:@TestMethodOrder(OrderAnnotation.class) ,方法上有 @Order(1)
IDEA Git工具集成测试功能
如果使用git 工具提交代码,可以设置 before cmmit 的时候执行某个单元测试集合

边栏推荐
- How to install PHP in CentOS
- 三相并网逆变器PI控制——离网模式
- 在SQL注入中,为什么union联合查询,id必须等于0
- Fragmenttabhost implements the interface of housing loan calculator
- 图像识别-数据清洗
- JVM instruction mnemonic
- idea查看字节码配置
- Record personal understanding and experience of game console configuration
- 2837xd Code Generation - stateflow (4)
- 图像识别-数据标注
猜你喜欢

TD conducts functional simulation with Modelsim

自定義Redis連接池

Customize redis connection pool

一次聊天勾起的回忆

2837xd 代码生成——StateFlow(3)

Chrome browser tag management plug-in – onetab

Personal experience & blog status

Fragmenttabhost implements the interface of housing loan calculator

Microservice practice | Eureka registration center and cluster construction

QT qlabel style settings
随机推荐
Beats (filebeat, metricbeat), kibana, logstack tutorial of elastic stack
在SQL注入中,为什么union联合查询,id必须等于0
道阻且长,行则将至
PI control of grid connected inverter (grid connected mode)
C语言之到底是不是太胖了
保存视频 opencv::VideoWriter
Bugkuctf-web16 (backup is a good habit)
Web security and defense
c语言编程题
攻防世界-Web进阶区-unserialize3
2837xd code generation - stateflow (3)
vs+qt 设置应用程序图标
2837xd code generation - Supplement (1)
Save video opencv:: videowriter
Bugkuctf-web21 (detailed problem solving ideas and steps)
MySQL default transaction isolation level and row lock
Learn combinelatest through a practical example
Don't look for it. All the necessary plug-ins for Chrome browser are here
三相逆变器离网控制——PR控制
TD conducts functional simulation with Modelsim