当前位置:网站首页>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 的时候执行某个单元测试集合

边栏推荐
- Methods of classfile
- What are the differences between TP5 and laravel
- 2837xd code generation - Supplement (3)
- Elastic Stack之Beats(Filebeat、Metricbeat)、Kibana、Logstash教程
- tinyxml2 读取和修改文件
- VIM操作命令大全
- Knife4j 2. Solution to the problem of file control without selection when uploading x version files
- C language programming problems
- Bugkuctf-web21 (detailed problem solving ideas and steps)
- 因上努力,果上随缘
猜你喜欢

Pool de connexion redis personnalisé

Error reporting on the first day of work (incomplete awvs unloading)

Tools used for Yolo object recognition and data generation

Kinect DK obtains color RGB images in cv:: mat format (used in openpose)

企业级SaaS CRM实现

MySQL default transaction isolation level and row lock

Memories of a chat

Customize redis connection pool

In depth analysis of how the JVM executes Hello World

上班第一天的报错(AWVS卸载不彻底)
随机推荐
PI control of grid connected inverter (grid connected mode)
Break the cocoon | one article explains what is the real cloud primordial
记录下对游戏主机配置的个人理解与心得
Read Day6 30 minutes before going to bed every day_ Day6_ Date_ Calendar_ LocalDate_ TimeStamp_ LocalTime
Don't look for it. All the necessary plug-ins for Chrome browser are here
Tools used for Yolo object recognition and data generation
Supplier selection and prequalification of Oracle project management system
c语言编程题
Navicat remote connection MySQL reports an error 1045 - access denied for user 'root' @ '222.173.220.236' (using password: yes)
每天睡觉前30分钟阅读_day3_Files
2837xd 代码生成——补充(3)
2837xd code generation - Summary
Bugkuctf-web21 (detailed problem solving ideas and steps)
Chrome browser tag management plug-in – onetab
cmake的命令-官方文档
Share a blog (water blog)
C语言之最小数
C语言之数据插入
2837xd 代码生成——StateFlow(4)
C语言之分草莓