Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
504 views
in Technique[技术] by (71.8m points)

maven - failsafe plugin won't run on one project but will run on another -- why?

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

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.

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

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...