当前位置:网站首页>在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.
参考文档
边栏推荐
- 中国十大证券app排名 炒股开户安全吗
- In 2021, big companies often ask IOS interview questions -- runloop
- [parameter configuration tutorial] how should the parameters in the RTMP streaming camera be configured?
- leetcode. 12 --- integer to Roman numeral
- Is industrial securities reliable? Is it safe to open a securities account?
- From practical teaching to competition exercise, Tencent experts personally teach Ti-One platform operation strategy!
- The industrial control security of roaming the Intranet
- update+catroot+c000021a+critical service failed+drivers+intelide+viaide+000000f
- Is it safe to open a stock account by mobile phone
- Is it safe to open an account for stock speculation in the top ten securities app rankings in China
猜你喜欢

FreeRTOS新建任务不执行问题解决办法

Stm32f1 and stm32cubeide programming examples -ws2812b full color LED driver (based on spi+dma)

A common defect management tool - Zen, which teaches you from installation to using the handle

I have been in the industry for 4 years and have changed jobs twice. I have learned a lot about software testing

设备通过国标GB28181接入EasyCVR平台,出现断流情况该如何解决?

Multimeter resistance measurement diagram and precautions

As a developer, what is the most influential book for you?

刚刚阿里面软件测试回来,3+1面任职阿里P7,年薪28*15薪

高速公路服务区智能一体机解决方案

How to generate assembly code using clang in Intel syntax- How to generate assembly code with clang in Intel syntax?
随机推荐
Is it safe to open a stock account by mobile phone
A common defect management tool - Zen, which teaches you from installation to using the handle
Step by step introduction to sqlsugar based development framework (9) -- Realizing field permission control with WinForm control
Esp32 series -- comparison of esp32 series
A full set of tutorials for interviewers from Android manufacturers teach you: prepare for the interview and get the offer smoothly!
Tencent cloud native intelligent data Lake Conference will be held, revealing the panoramic matrix of Tencent cloud data Lake products for the first time
Laravel8 uses faker to call factory to fill data
【我的OpenGL学习进阶之旅】OpenGL的坐标系的学习笔记
高速公路服务区智能一体机解决方案
Istio Troubleshooting: using istio to reserve ports causes pod startup failure
Since the household appliance industry has entered the era of stock competition, why does Suning win the first channel for consecutive times?
How to allow easydss online classroom system to upload an on-demand file with a space in the file name?
Is it safe to open an account for flush stock on mobile phone!
From practical teaching to competition exercise, Tencent experts personally teach Ti-One platform operation strategy!
Bosun query
openinstall携手书链:助力渠道数据分析,共创书联网时代
FPGA based analog I ² C protocol system design (medium)
How to achieve long-term development of voice social source code?
Phpcms upgrade editor method -- simple and effective
US Senate promotes bipartisan gun safety bill