junit-jupiter-api和junit-jupiter-engine之间的区别 [英] Difference between junit-jupiter-api and junit-jupiter-engine

查看:457
本文介绍了junit-jupiter-api和junit-jupiter-engine之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

maven模块junit-jupiter-apijunit-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

用于编写测试和扩展的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-apijunit-jupiter-engine来编写和运行JUnit5测试
  • 如果(a)您正在使用JUnit5运行,并且(b)您的测试用例使用了JUnit4构造/注释/规则等,则仅需要junit-vintage-engine
  • You need both junit-jupiter-api and junit-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之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆