我正在尝试使用 Maven 插件 Failsafe 来运行 src/it/java 目录中的集成测试。我正在使用 build-helper 插件来获取我的集成测试资源
我设置了我的故障保护插件,比如......
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<printSummary>true</printSummary>
</configuration>
</plugin>
使用我的构建助手插件设置,例如...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>
<directory>src/it/java</directory>
</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-resource</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/it/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
我也有 Surefire 插件来运行我的单元测试...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
当我执行 mvn clean verify 时,只有单元测试以 surefire 运行并且故障安全不运行,当我尝试 mvn failsafe:verify 时没有运行测试,当我尝试 mvn build-helper:add-test-sources failsafe:verify 时,它抛出无法找到测试源的错误。
[ERROR] Failed to execute goal org.codehaus.mojo:build-helper-maven-plugin:3.0.0:add-test-source (default-cli) on project stkweb: The parameters 'sources' for goal org.codehaus.mojo:build-helper-maven-plugin:3.0.0:add-test-source are missing or invalid -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
现在,如果我稍微改变一下配置,并将我的集成测试放在 src/test/java 文件夹中,它可以很好地运行它们。只是出于设计原因,我们希望它们位于单独的目录中。