7

这让我发疯。Maven 故障保护插件不会在我的项目上运行。如果我mvn verify只运行肯定会运行。如果我键入mvn failsafe:verify它会失败并出现以下错误:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Simulation Experiment Server 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-failsafe-plugin:2.11:verify (default-cli) @ experiment-server ---
[INFO] Failsafe report directory: C:\IdeaProjects\experiment_server\target\failsafe-reports
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.551s
[INFO] Finished at: Fri Mar 30 11:24:58 GMT-06:00 2012
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.11:verify (default-cli) on project experiment-server: C:\IdeaProjects\experiment_server\target\failsafe-reports\failsafe-summary.xml (The system cannot find the path specified) -> [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/MojoExecutionException

它抱怨找不到failsafe-summary.xml。但这应该由插件创建。该插件工作正常(failsafe-summary.xml如果我运行 Antonio Goncalves 精彩的Arquillian 示例项目,则会创建文件。

所以我复制了 Antonio 使用的确切插件信息,但它仍然无法在我的项目上运行。我已经将我的 POM 建模为与他的完全一样(除了没有父 pom)——一定是出了问题,我只是不知道是什么。为什么故障保护会在他的项目上运行而不是我的?

这是我的故障安全 pom.xml 条目,它取自他的,与故障安全 usaages 站点上的条目相同):

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>${version.maven.failsafe.plugin}</version>
    <configuration>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

感谢您的帮助,这让我发疯了。

更新好的,我似乎已经解决了cannot find failsafe-summary.xml问题——我将目录从 更改experiment_serverexperiment-server. 我想这会破坏故障安全。

但是,我仍然无法从命令mvn verifymvn integration-test. 这两个命令都调用surefire而不是failsafe。我现在可以使用命令直接运行故障安全:mvn failsafe:integration-test,但不应该自动运行故障安全mvn verify吗?我的mvn help:effective-pom节目表明故障安全存在,所以这不是问题......有什么想法吗?

4

4 回答 4

13

查看默认情况下期望的测试名称的故障安全文档:failsafe

<includes>
  <include>**/IT*.java</include>
  <include>**/*IT.java</include>
  <include>**/*ITCase.java</include>
</includes>

您的测试是否按照这些模式之一命名?如果没有,请尝试<includes>在插件配置中定义元素。或者更改您的测试名称以适应默认模式。


好的,现在我们已经验证了测试类名称 - 通常当我将执行添加到插件配置时,我会这样做:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>${version.maven.failsafe.plugin}</version>
    <configuration>
    </configuration>
    <executions>
        <execution>
            <id>failsafe-integration-tests</id>
            <phase>integration-test</phase>
            <goals>
                <goal>integration-test</goal>
            </goals>
        </execution>
        <execution>
            <id>failsafe-verify</id>
            <phase>verify</phase>
            <goals>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

failsafe这明确地将您要运行的插件目标绑定到构建生命周期的正确阶段。我相信surefire插件默认绑定到test生命周期阶段(无论如何对于 jar、war 和 ejb),但没有任何东西绑定到integration-testor verify

于 2012-03-30T19:32:14.377 回答
2

在这里,我将分享我的 2 美分。我有同样的问题,上面的解决方案没有解决我的问题。

我将 maven-failsafe-plugin 封装在pluginManagement标签中。当我在 4.0.0 maven 架构中看到这个文档时,我注意到将它移到插件标签中:

默认插件信息可供从该项目派生的项目参考。除非被引用,否则此插件配置不会被解析或绑定到生命周期。给定插件的任何本地配置都将在此处覆盖插件的整个定义。

希望这个额外的信息。解决了更多像我这样的人的问题。

于 2012-11-19T07:13:24.087 回答
1

对我来说,它只有在我添加了“默认”包含之后才起作用。

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.15</version>
        <configuration>
            <includes>
                <include>**/IT*.java</include>
                <include>**/*IT.java</include>
                <include>**/*ITCase.java</include>
                <include>**/IntegrationTest*.java</include>
            </includes>
        </configuration>
        <executions>
            <execution>
                <id>failsafe-integration-tests</id>
                <phase>integration-test</phase>
                <goals>
                    <goal>integration-test</goal>
                </goals>
            </execution>
            <execution>
                <id>failsafe-verify</id>
                <phase>verify</phase>
                <goals>
                    <goal>verify</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
于 2013-06-29T19:51:17.957 回答
0

If you are running 2.12.2 version of the failsafe plugin, this is normal. Switch to a previous version. It seem 2.13 is not available yet.

Jira link

于 2012-08-17T09:07:14.020 回答