当前位置:网站首页>在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.
参考文档
边栏推荐
- Very exciting! 12000 words summarized the theory of network technology, reviewing the old and learning the new
- 大智慧开户要选什么证券公司比较好,更安全一点
- leetcode 139. Word break word split (medium)
- Since the household appliance industry has entered the era of stock competition, why does Suning win the first channel for consecutive times?
- VIM common shortcut keys
- As a developer, what is the most influential book for you?
- 50 practical applications of R language (23) - important concepts of Bayesian Theory: credibility, model models, and parameters
- Design of vga/lcd display controller system based on FPGA (Part 2)
- 还在担心漏测吗?快来使用jacoco统计下代码覆盖率
- 期货公司开户安全吗
猜你喜欢
Redis consistency hash and hash slot

【C语言刷题——Leetcode12道题】带你起飞,飞进垃圾堆

Wide measuring range of jishili electrometer

How to generate assembly code using clang in Intel syntax- How to generate assembly code with clang in Intel syntax?
Record the range of data that MySQL update will lock

Laravel 8 realizes auth login

A brief introduction to the lexical analysis of PostgreSQL

Keyword of ES mapping; Term query add keyword query; Change mapping keyword type

From pair to unordered_ Map, theory +leetcode topic practice

Stm32f1 and stm32cubeide programming examples -ws2812b full color LED driver (based on spi+dma)
随机推荐
50 practical applications of R language (23) - important concepts of Bayesian Theory: credibility, model models, and parameters
设备通过国标GB28181接入EasyCVR平台,出现断流情况该如何解决?
安装wireshark时npcap怎么都安装不成功,建议先用winpcap
Low fidelity prototype vs high fidelity prototype, which one is more suitable for your design?
Xingxinghai, it is said that the new generation can fight better?
手机同花顺股票开户安全吗!
The future of robots -- deep space exploration
The 30 pictures bring the network protocol layer by layer to life. It's really fragrant!
How to build a high-performance go cache Library
Stm32f1 and stm32cubeide programming examples -ws2812b full color LED driver (based on spi+dma)
东方财富哪个开户更安全,更好点
How to resolve the 35 year old crisis? Sharing of 20 years' technical experience of chief architect of Huawei cloud database
Is industrial securities reliable? Is it safe to open a securities account?
实战 | 记一次曲折的钓鱼溯源反制
Left hand code, right hand open source, part of the open source road
When installing Wireshark, npcap cannot be installed successfully. It is recommended to use WinPcap first
Precautions for using JMeter suite to build a pressure test environment
FreeRTOS新建任务不执行问题解决办法
Two way combination of business and technology to build a bank data security management system
Golang implements BigInteger large number calculation