maven-failsafe-plugin Errors and BUILD SUCCESS?

删除回忆录丶 提交于 2019-12-03 23:00:48

You need having two executions blocks, cause the verify goal of the maven-failsafe-plugin is intended to check the results of the integration tests.

  <executions>
    <execution>
        <id>functional-test-1024</id>
        <phase>test</phase>
        <goals>
            <goal>integration-test</goal>
        </goals>
        <configuration>
            <includes>
                <include>**/IntegrationTierFunctionalTestCase.java</include>
            </includes>
            <forkMode>once</forkMode>
            <argLine>-XX:MaxPermSize=256M -Xmx1024M</argLine>
        </configuration>
    </execution>
    <execution>
        <id>verify</id>
        <phase>verify</phase>
        <goals>
            <goal>verify</goal>
        </goals>
    </execution>
  </executions>

Furthermore you should update the version of the maven-failsafe-plugin to 2.14.1 instead of 2.7. Update: In the meantime update to 2.17.

If you're running the integration tests like this:

mvn test-compile failsafe:integration-test

Then you should know that according to the maven documentation on failsafe:

The Failsafe Plugin will not fail the build during the integration-test phase, thus enabling the post-integration-test phase to execute.

I was able to get the build to fail like this:

mvn test-compile failsafe:integration-test failsafe:verify

And here's my failsafe configuration for reference:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.19</version>
            <configuration>
                <includes>
                    <include>**/*IT.java</include>
                </includes>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Please verify that the maven property "maven.test.failure.ignore" is not set to "true" in any of your maven pom.xml files, as it can be the only reason to not stop the build after test failure.

There is one possible additional reason why it happens. Failsafe verify is looking for test classes and expects them to be in ${project.build.directory}/test-classes - if you have a different setup it will just print "No tests to run." and ends if build success regardless of what the result of integration-test phase was.

You have to set testClassesDirectory in plugin configuration :

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.18.1</version>

            <configuration>
                <systemPropertyVariables>
                    <environmentType>${environmentType}</environmentType>
                </systemPropertyVariables>
                <summaryFile>${project.build.directory}/failsafe-reports/failsafe-summary.xml</summaryFile>
                <testClassesDirectory>${project.build.directory}/classes</testClassesDirectory>
                <suiteXmlFiles>
                    <suiteXmlFile>${suiteXml}</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!