默认情况下,Failsafe Plugin 将自动包含所有具有以下通配符模式的测试类:
如果测试类不符合命名约定,则配置故障安全插件并指定要包含的测试。
<project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.7.2</version> <configuration> <includes> <include>Sample.java</include> </includes> </configuration> <executions> <execution> <id>integration-test</id> <phase>integration-test</phase> <goals> <goal>integration-test</goal> </goals> </execution> <execution> <id>verify</id> <phase>verify</phase> <goals> <goal>verify</goal> </goals> </execution> </executions> </plugin> </plugins> </build> [...] </project>
有时某些测试会导致构建失败。排除它们是继续构建的最佳解决方法之一。可以通过配置插件的excludes属性来完成排除。
<project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.7.2</version> <configuration> <excludes> <exclude>**/CircleIT.java</exclude> <exclude>**/SquareIT.java</exclude> </excludes> </configuration> <executions> <execution> <id>integration-test</id> <goals> <goal>integration-test</goal> </goals> </execution> <execution> <id>verify</id> <goals> <goal>verify</goal> </goals> </execution> </executions> </plugin> </plugins> </build> [...] </project>