Error during Failsafe integration test does not cause failed Maven build

社会主义新天地 提交于 2019-12-23 13:11:11

问题


I have Failsafe running a Selenium integration test. If one of my assertions in the test does not pass and the test fails, then the Maven build will fail as expected. However, if the test errors, the build finishes unexpectedly as a success (output below)

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 14.075 sec <<< FAILURE!

Results :

Tests in error:
  test(uk.co.ned24.ExpandedIT)

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 minutes 40 seconds
[INFO] Finished at: Wed Jan 30 16:58:28 GMT 2013
[INFO] Final Memory: 78M/209M
[INFO] ------------------------------------------------------------------------

I'm not sure whether this is meant to happen or not and whether Selenium could cause unexpected behaviour? I've looked at the plugin doco and can't find any flags that can be set to make the build fail after a test error.

Ideally I'd like to make the build fail on test error, so would appreciate any advice! I've attached the Failsafe snipped from my POM in case that's of use.

thanks, Nick

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

回答1:


You should call mvn verify instead of mvn integration-test.

Quoting the Failsafe Plugin page (emphasis mine):

The Failsafe Plugin is used during the integration-test and verify phases of the build lifecycle to execute the integration tests of an application. The Failsafe Plugin will not fail the build during the integration-test phase thus enabling the post-integration-test phase to execute.

NOTE: when running integration tests, you should invoke maven with the (shorter to type too)

mvn verify

rather than trying to invoke the integration-test phase directly, as otherwise the post-integration-test phase will not be executed.




回答2:


You should set the version of the maven-failsafe-plugin. For example to 2.14.1.

And your integration test classes must have ending "IntegrationTest", for example: CustomDaoIntegrationTest



来源:https://stackoverflow.com/questions/14614374/error-during-failsafe-integration-test-does-not-cause-failed-maven-build

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