本文介绍了故障安全插件不会在一个项目上运行,但会在另一个项目上运行——为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我发疯.Maven 故障安全插件不会在我的项目上运行.如果我运行 mvn verify 则只运行surefire.如果我输入 mvn failsafe:verify 它会失败并显示以下错误:

This is driving me insane. The Maven failsafe plugin will not run on my project. If I run mvn verify only surefire runs. If I type mvn failsafe:verify it fails with the following error:

[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:IdeaProjectsexperiment_server	argetfailsafe-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:IdeaProjectsexperiment_server	argetfailsafe-reportsfailsafe-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.但这应该由插件创建.并且该插件运行良好(如果我运行运行 Antonio Goncalves 精彩 .

It's complaining about not finding failsafe-summary.xml. But this should be created by the plugin. And the plugin works fine (and creates the failsafe-summary.xml file if I run run Antonio Goncalves wonderful Arquillian example project.

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

So I copied the exact plugin information Antonio uses, and it still won't run on my project. I've modelled my POM to be exactly like his (except without a parent pom) -- something must be going wrong, I just don't know what. Why will failsafe run on his project but not mine??

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

Here is my failsafe pom.xml entry, which is taken right from his, and is the same as the one on the failsafe usaages site):

<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>

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

Thanks for any help, this is driving me insane.

UPDATE 好的,我似乎已经解决了 cannot find failsafe-summary.xml 问题——我从 experiment_server 更改了我的目录到 experiment-server.我想这会搞砸故障保护.

UPDATE Okay, I seem to have gotten the cannot find failsafe-summary.xml problem fixed -- I change my directory from experiment_server to experiment-server. I guess that messes up failsafe.

但是,我仍然无法通过命令 mvn verifymvn integration-test 运行故障安全.这两个命令都调用surefire而不是failsafe.我现在可以使用以下命令直接运行故障安全:mvn failsafe:integration-test,但是故障安全不应该与 mvn verify 一起自动运行吗?我的 mvn help:effective-pom 显示故障安全在那里,所以这不是问题......有任何想法吗?

But, I'm still having trouble getting failsafe to run from the command mvn verify or mvn integration-test. Both those commands call surefire instead of failsafe. I can now run failsafe directly by using the command: mvn failsafe:integration-test, but shouldn't failsafe automatically run with mvn verify? My mvn help:effective-pom shows that failsafe is there, so that's not the problem... Any ideas?

推荐答案

查看failsafe docs 用于 failsafe 默认期望的测试名称:

Take a look at the failsafe docs for the test names failsafe expects by default:

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

您的测试是否遵循这些模式之一命名?如果没有,请尝试在插件配置中定义 元素.或者更改您的测试名称以适合默认模式.

Are your tests named following one of these patterns? If not, try defining the <includes> element in the plugin configuration. Or change your test name(s) to fit the default pattern.

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

Okay, now that we've verified the test class names - typically when I add executions to plugin config I do it something like this:

<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-testverify.

This explicitly binds the failsafe plugin goals you want to run to the correct phases of the build lifecycle. I believe the surefire plugin is bound to the test lifecycle phase by default (for a jar, war, & ejb anyway), but nothing is bound to integration-test or verify.

这篇关于故障安全插件不会在一个项目上运行,但会在另一个项目上运行——为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-30 05:34