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

隐身守侯 提交于 2019-11-27 02:09:57
user944849

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.

Here I will share my 2 cents. I had same issue and solution above didn't solve my problem.

I had maven-failsafe-plugin encapsulated in pluginManagement tag. I noticed to move it out into plugins tag instead when I saw this doc in the 4.0.0 maven schema:

Default plugin information to be made available for reference by projects derived from this one. This plugin configuration will not be resolved or bound to the lifecycle unless referenced. Any local configuration for a given plugin will override the plugin's entire definition here.

Hopefully this additional info. solves more ppl's problem like myself.

For me it worked only after I added the "default" includes.

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!