因为我是 Junit 5 的新手,我读到它们现在在 Junit 5 中是分开的罐子,所以我需要附加什么?
我正在查看 Maven 存储库,我发现 Junit 5 有很多依赖项,我不知道在 Junit 5 中运行 Junit 4 测试应该包含什么,以及单独针对 Junit 5 的内容是什么?
我还没有代码,但只需要依赖项来理解我的内容需要下载
还有万无一失对所有这些做了什么?
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.0-M4</version>
</dependency>
更新 - 所以确定火用于搜索缺少的依赖项,做什么?
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.4.0-M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.4.0-M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-api</artifactId>
<version>1.4.0-M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.4.0-M1</version>
<scope>test</scope>
</dependency>
问题:万无一失对所有这些有什么作用?
如果在 POM 中.xml您的依赖项没有被很好地提及,那么 Surefire 会检测要使用的 JUnit 版本。
Surefire 支持 3 代不同的 JUnit:JUnit 3.8.x、JUnit 4.x(串行提供程序)和 JUnit 4.7(具有并行支持的 junit 核心提供程序)
该算法的工作方式如下:
if the JUnit 5 Platform Engine is present in the project
use junit-platform
if the JUnit version in the project >= 4.7 and the <<<parallel>>> configuration parameter has ANY value
use junit47 provider
if JUnit >= 4.0 is present
use junit4 provider
else
use junit3.8.1
编辑:Junit 5 所需的依赖项:ref1 , ref2
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
参考