当前位置:网站首页>在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.
参考文档
边栏推荐
- Is it safe to open a stock account by mobile phone
- Redis highly available
- 刚刚阿里面软件测试回来,3+1面任职阿里P7,年薪28*15薪
- Why is the blackmail virus that shut down half of America's energy system terrible? Interpretation of authoritative reports
- 中国十大证券app排名 炒股开户安全吗
- 一个简单而功能强大的开发者工具箱Box3.cc
- Analysis of similarities and differences between redis and memcached in cache use
- A series of problems caused by IPVS connection reuse in kubernetes
- 期货公司开户安全吗
- Data stack technology sharing: how to use data stack for data collection?
猜你喜欢

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
An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!

【我的OpenGL学习进阶之旅】OpenGL的坐标系的学习笔记

为什么企业实施WMS仓储管理系统很容易失败
Redis consistency hash and hash slot
Oracle RAC configuration multipathing

CVPR 2022 - Interpretation of selected papers of meituan technical team

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

Method after charging the idea plug-in material theme UI
随机推荐
手机同花顺股票开户安全吗!
How to generate assembly code using clang in Intel syntax- How to generate assembly code with clang in Intel syntax?
刚刚阿里面软件测试回来,3+1面任职阿里P7,年薪28*15薪
Huangchuping presided over the video conference on fixed-point contact with Zhuhai, resolutely implemented the deployment requirements of the provincial Party committee, and ensured positive results i
Easynvr has been connected to the third-party supervision platform. How to achieve local Internet access
Laravel 8 realizes auth login
高速公路服务区智能一体机解决方案
[sdx62] wcn685x IPA registration failure analysis and solution
Improving the classification of motor imagery by combining EEG and MEG signals in BCI
Do you really know the difference between H5 and applet?
QTreeWidget作为单例模式以dll返回的两个问题
Industry cases of successful digital transformation
Is it safe for futures companies to open accounts
Who do you want to open a stock account? Is online account opening safe?
A series of problems caused by IPVS connection reuse in kubernetes
Xingxinghai, it is said that the new generation can fight better?
Keyword of ES mapping; Term query add keyword query; Change mapping keyword type
50 practical applications of R language (23) - important concepts of Bayesian Theory: credibility, model models, and parameters
"Industry foresight" future development trend of intelligent security monitoring industry
golang中Map的并发写入