maven-surefire-plugin include/exclude precedence
当使用 maven-surefire-plugin 并且包含和排除时,它们的处理顺序是什么?此外,如果您有 3 组测试,第一组是基本集,第二组和第三组是特殊情况,是否可以使用配置文件来进一步包含/排除?如何合并配置文件包含/排除设置?例如,我想做这样的事情:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.2</version>
<configuration>
<excludes>
<exclude>/org/mycompany/dataset/test/ExtractProd*.java</exclude> <!-- requires special network connectivity -->
<exclude>/org/mycompany/dataset/test/LargeDataset*.java</exclude> <!-- requires lengthy processing -->
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>connectedToProdNetwork</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>/org/mycompany/dataset/test/ExtractProd*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>runForAsLongAsYouNeed</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>/org/mycompany/dataset/test/LargeDataset*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
然后能够像这样运行:
mvn package -P connectedToProdNetwork
或
mvn package -P runForAsLongAsYouNeed
或
mvn package -P connectedToProdNetwork,runForAsLongAsYouNeed
----更新-----
使用我能够确定,如果我指定单个配置文件,则生成的有效pom将是:mvn help:effective-pom -P [profileA]
<configuration>
<includes>
<include>[includeFromProfileA]</include>
</includes>
<excludes>
<exclude>/org/mycompany/dataset/test/ExtractProd*.java</exclude> <!-- requires special network connectivity -->
<exclude>/org/mycompany/dataset/test/LargeDataset*.java</exclude> <!-- requires lengthy processing -->
</excludes>
</configuration>
如果我提供多个配置文件,请执行以下操作:mvn help:effective-pom -P [profileA],[profileB]
<configuration>
<includes>
<include>[includeFromProfileAOrBSeeminglyArbitraryChoice]</include>
</includes>
<excludes>
<exclude>/org/mycompany/dataset/test/ExtractProd*.java</exclude> <!-- requires special network connectivity -->
<exclude>/org/mycompany/dataset/test/LargeDataset*.java</exclude> <!-- requires lengthy processing -->
</excludes>
</configuration>
最后,如果我将属性 combine.children=“append”
添加到配置文件配置的元素中,并提供两个配置文件,则:<includes>
mvn help:effective-pom -P [profileA],[profileB]
<configuration>
<includes combine.children="append">
<include>[includeFromProfileA]</include>
<include>[includeFromProfileB]</include>
</includes>
<excludes>
<exclude>/org/mycompany/dataset/test/ExtractProd*.java</exclude> <!-- requires special network connectivity -->
<exclude>/org/mycompany/dataset/test/LargeDataset*.java</exclude> <!-- requires lengthy processing -->
</excludes>
</configuration>
但是,现在每个文件都同时指定为 an 和 an ,会发生什么情况?<include>
<exclude>
----更新 2 ----
实际运行具有以下配置的生成:
<configuration>
<includes>
<include>**/TestA.java</include>
</includes>
<excludes>
<exclude>**/TestA.java</exclude>
</excludes>
</configuration>
不运行 TestA,因此它似乎是一个意志压倒了 .请注意,为了完整起见,我确实颠倒了顺序,并在<包括>
之前放置了<排除>
但行为没有改变。如果有人能找到源代码以外的某个地方来概述这种行为,我很乐意给他们答案......<exclude>
<include>