[英]Maven command mvn clean verify does not activate Failsafe to run integration-tests
我正在嘗試使用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
現在,如果我稍微更改一下surefire的配置,並將集成測試放在src / test / java文件夾中,它將可以很好地運行它們。 出於設計原因,我們只是希望將它們放在單獨的目錄中。
問題歸結於使用<pluginManagement>
標記。
<build>
<pluginManagement>
<plugins>
</plugins>
</pluginManagement>
</build>
當我刪除pluginManagement標記時,它開始運行FailSafe。
<build>
<plugins>
</plugins>
</build>
這也解決了我們在直接致電Jacoco之前與Jacoco所遇到的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.