简体   繁体   English

发生异常时,JBehave不会失败构建

[英]JBehave does not fail build when exception occurs

I am using JBehave to run tests written using WebDriver. 我正在使用JBehave运行使用WebDriver编写的测试。 Maven is used to automate build process. Maven用于自动化构建过程。 And now when I run tests and they fail ie throwing exceptions about timeouts etc the whole build does not break. 现在,当我运行测试并失败时,即引发有关超时等的异常,整个构建不会中断。

Here is sample output with exception: 这是带有异常的示例输出:

pastebin 糊盒

Can anyone tell me why build does not fail after that and how to make it fail? 谁能告诉我为什么构建在此之后不会失败以及如何使其失败? If you need more info please let me know what. 如果您需要更多信息,请告诉我。

设置org.jbehave.core.configuration.Configuration对象时,添加:

myConfiguration.usePendingStepStrategy(new FailingUponPendingStep())

In my project I use maven-failsafe-plugin to execute tests and I encountered the same problem. 在我的项目中,我使用maven-failsafe-plugin执行测试,并且遇到了相同的问题。 The solution is to add a verify phase to failsafe: 解决方案是将验证阶段添加到故障保护:

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <executions>
        <execution>
        <id>failsafe-verify</id>
        <phase>verify</phase>
        <goals>
            <goal>verify</goal>
        </goals>
        </execution>
    </executions>
  </plugin>
</plugins>

While 5 years late, and not actually an answer to the question asked in 2012, jBehave 4.0 has a bug where Maven runs do not trigger a failure from Maven when using jBehave 4.0+ . 尽管晚了5年,但实际上并没有回答2012年提出的问题,但jBehave 4.0有一个错误, 即使用jBehave 4.0+时 ,Maven运行不会触发Maven失败

So if you've gotten here from Googling in 2017 or 2018, check out the ticket as it may contain answers to your problem (which, as of this writing in 2017, is "downgrade to 3.9.5...) 因此,如果您是在2017年或2018年从谷歌搜索而来的,请查看票证,因为其中可能包含您问题的答案(截至2017年,本文已“降级为3.9.5 ...”)

可能设置以下属性会有所帮助: -Dignore.failure.in.view=false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM