故障安全集成测试期间的错误不会导致失败的Maven构建 [英] Error during Failsafe integration test does not cause failed Maven build

查看:97
本文介绍了故障安全集成测试期间的错误不会导致失败的Maven构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有运行Selenium集成测试的Failsafe.如果我在测试中的断言之一没有通过且测试失败,则Maven构建将按预期失败.但是,如果测试错误,则构建会成功完成(输出如下)

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

我不确定这是否会发生以及硒是否会导致意外行为?我查看了插件doco,找不到测试错误后可以设置以使构建失败的任何标志.

理想情况下,我想使构建因测试错误而失败,因此不胜感激!我已经附上了我的POM附带的故障保护功能,以防万一.

谢谢,尼克

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

解决方案

您应该调用mvn verify而不是mvn integration-test.

引用故障保护插件页面(重点是我):

故障安全插件用于构建生命周期的集成测试和验证阶段,以执行应用程序的集成测试.故障保护插件在集成测试阶段不会使构建失败,从而使集成测试后阶段能够执行.

注意:在运行集成测试时,您应使用(也要短键入)来调用 maven.

mvn验证

而不是尝试直接调用集成测试阶段,否则将不执行集成后测试阶段.

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>

解决方案

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.

这篇关于故障安全集成测试期间的错误不会导致失败的Maven构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆