当前位置:网站首页>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 的时候执行某个单元测试集合
边栏推荐
- int与string、int与QString互转
- 个人经历&&博客现状
- 分布式锁的这三种实现方式,如何在效率和正确性之间选择?
- Save video opencv:: videowriter
- kinect dk 获取CV::Mat格式的彩色RGB图像(openpose中使用)
- Customize redis connection pool
- Methods of classfile
- Cmake command - Official Document
- Tools used for Yolo object recognition and data generation
- Off grid control of three-phase inverter - PR control
猜你喜欢
Break the cocoon | one article explains what is the real cloud primordial
Read 30 minutes before going to bed every day_ day4_ Files
MySQL default transaction isolation level and row lock
tinyxml2 读取和修改文件
Don't look for it. All the necessary plug-ins for Chrome browser are here
Supplier selection and prequalification of Oracle project management system
JDBC review
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
Chrome browser plug-in fatkun installation and introduction
How to use pyqt5 to make a sensitive word detection tool
随机推荐
Learn combinelatest through a practical example
QT QLabel样式设置
Timed thread pool implements request merging
上班第一天的报错(Nessus安装winpcap报错)
Microservice practice | Eureka registration center and cluster construction
QT信号槽总结-connect函数错误用法
在SQL注入中,为什么union联合查询,id必须等于0
Share a blog (water blog)
What are the waiting methods of selenium
Bugkuctf-web16 (backup is a good habit)
PI control of grid connected inverter (grid connected mode)
Typora安装包分享
Read 30 minutes before going to bed every day_ day4_ Files
Hystrix implements request consolidation
Tinyxml2 reading and modifying files
Inverter Simulink model -- processor in the loop test (PIL)
因上努力,果上随缘
C语言之数据插入
Bugkuctf-web21 (detailed problem solving ideas and steps)
2837xd Code Generation - stateflow (4)