【问题标题】:JBehave does not fail build when exception occurs发生异常时,JBehave 不会失败构建
【发布时间】:2023-03-07 14:06:01
【问题描述】:

我正在使用 JBehave 运行使用 WebDriver 编写的测试。 Maven 用于自动化构建过程。现在,当我运行测试并且它们失败时,即抛出有关超时的异常等,整个构建不会中断。

这是异常的示例输出:

pastebin

谁能告诉我为什么在那之后构建不会失败以及如何让它失败?如果您需要更多信息,请告诉我什么。

【问题讨论】:

    标签: java maven build jbehave


    【解决方案1】:

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

    myConfiguration.usePendingStepStrategy(new FailingUponPendingStep())
    

    【讨论】:

    • 这个注解还不够:@Configure(storyReporterBuilder = MyReportBuilder.class, pendingStepStrategy = FailingUponPendingStep.class) ?
    【解决方案2】:

    在我的项目中,我使用 maven-failsafe-plugin 执行测试,我遇到了同样的问题。解决方案是在故障安全中添加验证阶段:

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

    【讨论】:

      【解决方案3】:

      虽然晚了 5 年,实际上并没有回答 2012 年提出的问题,但 jBehave 4.0 存在 Maven 运行 do not trigger a failure from Maven when using jBehave 4.0+ 的错误。

      因此,如果您是 2017 年或 2018 年从 Google 搜索到这里的,请查看该票证,因为它可能包含您问题的答案(截至 2017 年撰写本文时,该票证是“降级到 3.9.5...)

      【讨论】:

        【解决方案4】:

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

        【讨论】:

          猜你喜欢
          • 2021-04-15
          • 2022-06-14
          • 1970-01-01
          • 2021-11-11
          • 1970-01-01
          • 1970-01-01
          • 2019-12-10
          • 1970-01-01
          相关资源
          最近更新 更多