如何通过命令行选项使用Maven Surefire排除标签? [英] How to exclude tags with Maven Surefire via command line options?

查看:100
本文介绍了如何通过命令行选项使用Maven Surefire排除标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从通过命令行传递的Java系统道具的测试执行中排除标记,但是它不起作用.

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.

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"

输出:

NotThreadSafe
It's ok

但是-Dgroups属性可以正常工作:

But -Dgroups propery works fine:

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

输出:

NotThreadSafe

推荐答案

如此处所述: https://github.com/junit-team/junit5/issues/1612#issuecomment-426217199

我们需要使用标记表达式

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

这篇关于如何通过命令行选项使用Maven Surefire排除标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆