JUnit 5 TestSuite替代方案?

Bos*_*ssk 7 java junit5

我正在从JUnit 4迁移到5,并决定将所有旧的@Tests重写为新的org.junit.jupiter.api.Test.

我的目标是完全删除旧的junit4依赖项,只保留这些依赖项:

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-api</artifactId>
    <version>5.0.1</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>5.0.1</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.junit.platform</groupId>
    <artifactId>junit-platform-runner</artifactId>
    <version>1.0.1</version>
    <scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

到目前为止,我已经重写了除了我的TestSuites之外的所有东西,我用它将所有测试集群到4个独立的套件中,可以通过surefire插件调用.

似乎JUnit 5根本没有声明性套件支持,但确实有@Tag注释.

题:

我怎样才能创建某种类型的测试套件 - 仅使用JUnit 5的东西,可以使用maven-surefire-plugin(<includes>)和可运行的IntelliJ 调用?

Joh*_*ill 6

尽管有丰富的 junit-platform-suite-api,但目前(2018 年 6 月)无法实现,因为平台中不支持本机测试套件。相反,您必须使用依赖于 junit-4.12.jar 的 junit-platform-runner 来识别和运行套件。

@RunWith(JUnitPlatform.class)
@SelectClasses({Dog.class, Cat.class})
public class MyTestSuite {
}
Run Code Online (Sandbox Code Playgroud)

但是,根据此 github 问题,该平台的 1.3 版本可能会提供本机支持。

我删除了所有测试套件,以避免在我的项目中使用 junit 4。当新功能可用时,我会很高兴地再次创建它们。