配置 maven-failafe-plugin 以查找不在 src/test/java 中的集成测试
2022-09-03 15:29:04
我的目录结构是这样的:
src/integrationTest/java
src/test/java
src/main/java
我试图获得故障安全来拾取集成测试,但未能以我想要的方式做到这一点。
我试过这个:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<testSourceDirectory>src/integrationTest/java</testSourceDirectory>
<testClassesDirectory>${project.build.directory}/it-classes</testClassesDirectory>
</configuration>
</plugin>
和这个:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>src/integrationTest/**/*.java</include>
</includes>
</configuration>
</plugin>
无济于事;故障安全找不到要运行的测试。
我已经能够使用build-helper-maven插件来添加测试源目录,然后故障安全运行测试。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-integration-test-source-as-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/integrationTest/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
但是,现在的问题是,surefire 现在也将测试作为单元测试运行。此外,当故障安全应该能够找到测试时,似乎没有必要使用另一个插件;我宁愿不需要使用构建助手maven插件并配置sururefire以排除该路径。
我做错了什么?