maven模块junit-jupiter-api和junit-jupiter-engine有什么区别?是否有必要在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上添加一个依赖项
发布于 2018-01-25 17:12:17
版本5.4之前的JUnit
来自医生们
junit-jupiter-api用于编写测试和扩展的JUnit木星API。junit-jupiter-engineJUnit木星测试引擎实现,仅在运行时需要。junit-vintage-engineJUnit Vintage测试引擎实现,允许在新的JUnit平台上运行老式JUnit测试,即以JUnit 3或JUnit 4风格编写的测试。
所以..。
junit-jupiter-api和junit-jupiter-engine来编写和运行JUnit5测试。junit-vintage-engine:(a)运行JUnit5 和 (b)测试用例使用JUnit4构造/注释/规则等从5.4版开始的JUnit
在JUnit 5.4中,这是简化的,有关更多细节,请参见这个答案。
发布于 2019-03-10 02:57:29
junit-jupiter聚集器伪影
如果您的目的是编写JUnit 5.4提供 5测试,则Maven配置要简单得多。只需指定名为junit-jupiter的聚合工件。
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.1</version>
<scope>test</scope>
</dependency>作为一个集合,为了您的方便,这个工件会自动地提取以下三个工件:
junit-jupiter-api (编译依赖项)junit-jupiter-params (编译依赖项)junit-jupiter-engine (运行时依赖项)在您的项目中,您还将得到以下结果:
以上是编写和运行基于新木星范式的JUnit 5测试所需的内容。
遗留测试
如果您的项目有要继续运行的JUnit 3或4测试,则为JUnit Vintage引擎junit-vintage-engine添加另一个依赖项。见IBM教程。
<!-- https://mvnrepository.com/artifact/org.junit.vintage/junit-vintage-engine -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.9.1</version>
<scope>test</scope>
</dependency>发布于 2018-11-18 23:56:35
请注意,junit-jupiter-api作为子依赖项包含在junit-jupiter-engine Maven存储库中。因此,您只需要添加junit-jupiter-engine就可以得到这两个结果。我相信gradle也是一样的。https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine/5.1.1
https://stackoverflow.com/questions/48448331
复制相似问题