【问题标题】:Using JUnit 5 how can I test special tagged test methods使用 JUnit 5 如何测试特殊的标记测试方法
【发布时间】:2018-08-13 07:53:04
【问题描述】:

如何使用 JUnit 5 和 maven 命令测试特殊标记的测试方法。 例如,我在不同的类中有 2 个用 @unit 和 @integration 标记的测试方法,并且这些类也在测试源下的不同包中。我希望 maven 在执行 mvn -Dtag=unit 命令时只测试@unit 标记测试,或者在执行 mvn -Dtag=integration 命令时只测试@integration 标记测试

【问题讨论】:

    标签: java maven tags maven-surefire-plugin junit5


    【解决方案1】:

    参见https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit-platform.html 处的按标签过滤部分——您必须使用groupsexcludedGroups 元素。

    硬编码示例:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>
                <groups>unit</groups>
            </configuration>
        </plugin>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-07
      • 1970-01-01
      • 2021-12-30
      • 1970-01-01
      • 2020-04-20
      相关资源
      最近更新 更多