简体   繁体   English

如何通过命令行选项使用 Maven Surefire 排除标签?

[英]How to exclude tags with Maven Surefire via command line options?

I'm trying to exclude a tag from test execution with Java system props that are passed via the command line, but it's not working.我正在尝试使用通过命令行传递的 Java 系统道具从测试执行中排除标签,但它不起作用。

public class A {

    @Test
    @Tag("NotThreadSafe")
    public void test(){
        System.out.println("NotThreadSafe");
    }

    @Test
    public void test2(){
        System.out.println("It's ok");
    }
}

$: mvn clean test -Dtest="**/selftest/**" -DexcludeTags="NotThreadSafe"

Output:输出:

NotThreadSafe
It's ok

But -Dgroups propery works fine:但是 -Dgroups 属性工作正常:

$: mvn clean test -Dtest="**/cdp/autotests/selftest/**" -Dgroups="NotThreadSafe"

Output:输出:

NotThreadSafe

As mentioned here: https://github.com/junit-team/junit5/issues/1612#issuecomment-426217199正如这里提到的: https : //github.com/junit-team/junit5/issues/1612#issuecomment-426217199

We need to use Tag expressions我们需要使用标签表达式

mvn clean test -Dtest="**/selftest/**" -Dgroups=\!NotThreadSafe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM