问题描述
maven模块junit-jupiter-api
和junit-jupiter-engine
有什么区别?是否有必要在build.gradle
中包括两个依赖项?
What is difference between maven modules junit-jupiter-api
and junit-jupiter-engine
? Is it necessary to include both dependencies in build.gradle
?
我是否需要像
testCompile("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
testCompile("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
或
testCompile("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
够了吗?
我是否需要添加对junit-vintage-engine
的依赖关系?
And do I need to add dependency on junit-vintage-engine
?
推荐答案
5.4之前的JUnit
来自文档 :
用于编写测试和扩展的JUnit Jupiter API.
JUnit Jupiter API for writing tests and extensions.
junit-jupiter-engine
junit-jupiter-engine
JUnit Jupiter测试引擎实现,仅在运行时需要.
JUnit Jupiter test engine implementation, only required at runtime.
junit-vintage-engine
junit-vintage-engine
JUnit Vintage测试引擎实现,允许在新的JUnit平台上运行Vintage JUnit测试,即以JUnit 3或JUnit 4样式编写的测试.
JUnit Vintage test engine implementation that allows to run vintage JUnit tests, i.e. tests written in the JUnit 3 or JUnit 4 style, on the new JUnit Platform.
所以...
- 您需要
junit-jupiter-api
和junit-jupiter-engine
来编写和运行JUnit5测试 - 如果(a)您正在使用JUnit5运行,并且(b)您的测试用例使用了JUnit4构造/注释/规则等,则仅需要
junit-vintage-engine
- You need both
junit-jupiter-api
andjunit-jupiter-engine
to write and run JUnit5 tests - You only need
junit-vintage-engine
if (a) you are running with JUnit5 and (b) your test cases use JUnit4 constructs/annotations/rules etc
在JUnit 5.4中,这已简化,请参见此答案以获取更多详细信息.
In JUnit 5.4 this is simplified, see this answer for more details.
这篇关于junit-jupiter-api和junit-jupiter-engine之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!