当前位置:网站首页>在Gradle 中对Junit5 测试框架引用
在Gradle 中对Junit5 测试框架引用
2022-06-24 15:33:00 【独家雨天】
Junit5 是最近众所周知的Junit 测试框架。Junit5是模块化的,并且由不同的模块组成。
JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage
- JUnit Platform是在JVM上启动测试框架的基础。
- JUnit Jupiter是新编程模型和扩展模型的组合,用于在JUnit 5中编写测试和扩展。
- JUnit Vintage提供了一个TestEngine,用于在平台上运行基于JUnit 3和JUnit 4的测试。
在build.gradle中写下如下代码来支持运行 Junit Platform
test {
useJUnitPlatform()
}
可以在 useJUnitPlatform 中查看更多细节。
Compiling and executing JUnit Jupiter tests
为了支持Junit Jupiter ,可以添加如下依赖
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.1.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.1.0")
}
然后就可以写代码,并且运行 gradle test 来执行。
Executing legacy tests with JUnit Vintage
就如前面所写,如果你想运行 Junit3/4,或者是同 Jupiter tests混合运行,那么需要引入 JUnit Vintage Engine 依赖。
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.1.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.1.0")
testCompileOnly("junit:junit:4.12")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.1.0")
}
Junit Platform 允许使用不同的测试引擎, Junit 当前提供了两种开箱即用的 TestEngine,junit-jupiter-engine and junit-vintage-engine.。当然也可以自自定义自己的实现的详细说明可以点击链接.
默认情况下,所有的测试引擎都会在测试运行期间使用,但如果想显示的实现具体的测试引擎,可以添加如下的配置来实现Filter specific engines。
tasks.test {
useJUnitPlatform {
includeEngines("junit-vintage")
// excludeEngines("junit-jupiter")
}
}
A test engine filtering sample can be found at samples/testing/junitplatform/engine in the ‘-all’ distribution of Gradle.
参考文档
边栏推荐
- 时间同步业务的闭环管理——时间监测
- Chaos mesh in Tencent -- Tencent mutual entertainment chaotic engineering practice
- 【我的OpenGL学习进阶之旅】OpenGL的坐标系的学习笔记
- The security market has entered a trillion era, and the security B2B online mall system has been accurately connected to deepen the enterprise development path
- Istio FAQ: 431 request header fields too large
- Redis consistency hash and hash slot
- I have been in the industry for 4 years and have changed jobs twice. I have learned a lot about software testing
- Is industrial securities reliable? Is it safe to open a securities account?
- QoS Technology in network
- From practical teaching to competition exercise, Tencent experts personally teach Ti-One platform operation strategy!
猜你喜欢
为什么企业实施WMS仓储管理系统很容易失败
Record the range of data that MySQL update will lock
Linux记录-4.22 MySQL5.37安装(补充)
Multimeter resistance measurement diagram and precautions
CVPR 2022 - Interpretation of selected papers of meituan technical team
leetcode. 12 --- integer to Roman numeral
刚刚阿里面软件测试回来,3+1面任职阿里P7,年薪28*15薪
熬夜整理出的软件测试【高频】面试题大全(2022最新)
Bert whitening vector dimension reduction and its application
Oracle RAC configuration multipathing
随机推荐
Is it safe to open an account for flush stock on mobile phone!
An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!
Istio Troubleshooting: using istio to reserve ports causes pod startup failure
Linux记录-4.22 MySQL5.37安装(补充)
Analysis of dompurify
SF express: please sign for MySQL soul ten
From practical teaching to competition exercise, Tencent experts personally teach Ti-One platform operation strategy!
How to resolve the 35 year old crisis? Sharing of 20 years' technical experience of chief architect of Huawei cloud database
Differential privacy
update+catroot+c000021a+critical service failed+drivers+intelide+viaide+000000f
Cloud + community [play with Tencent cloud] essay solicitation activity winners announced
How to build a high-performance go cache Library
FreeRTOS新建任务不执行问题解决办法
The 30 pictures bring the network protocol layer by layer to life. It's really fragrant!
How to modify the login user name of easynvr video monitoring system?
Unimelb COMP20008 Note 2019 SM1 - Data formats
This website teaches you to imitate more than 100 well-known websites!
Service visibility and observability
Cvpr2022 | domaine compact adaptable
兴业证券靠谱吗?开证券账户安全吗?