如何将 excludeGroups 参数添加到 Maven 命令

2Bi*_*all 2 junit maven maven-surefire-plugin

我的 parent/pom.xml 文件中有 2 个 maven 配置文件。

第一个配置文件只运行某个组。

<configuration>
<groups>com.XXXXXXX.common.daily.util.UnitTest</groups> 
</configuration>
Run Code Online (Sandbox Code Playgroud)

第二个配置文件运行所有测试。

我想 在第二个配置文件中的maven 命令上使用一个参数来排除这个:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                <groups>com.XXXXXX.common.daily.util.UnitTest</groups> 
                   <skipTests>${skipFastTests}</skipTests>
                </configuration>
            </plugin>
Run Code Online (Sandbox Code Playgroud)

我不想更改第二个配置文件的 pom.xml。

我想知道如何为 excludeGroups 添加附加参数?

mvn test -P=profile2   ______
Run Code Online (Sandbox Code Playgroud)

小智 11

您可以在 pom 文件的插件配置中排除类别。但是如果你想通过 mvn 命令行动态排除给定的组,你可以使用“excludedGroups”参数来做到这一点,如下所示:

mvn test -DexcludedGroups=com.group.ExcludedCategory
Run Code Online (Sandbox Code Playgroud)

http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#excludedGroups