【问题标题】:Maven sure fail build when a test timeout is reached even when fail-on-end set to true当达到测试超时时,Maven 肯定会失败构建,即使失败时设置为 true
【发布时间】:2020-04-02 05:02:24
【问题描述】:

在多模块 maven 项目中,我想打印线程转储并在达到测试超时时使测试失败。所以为了实现这一点,我使用了TimedoutTestsListener 和surefire listener property 的组合。

我正在使用 Jenkins,因此将 fail-on-end 设置为 true,以便所有未受影响的测试继续运行,如 here 所述。

那么,是否有可能只有在达到超时时才立即使构建失败,而在其他失败情况下最终失败?

  • JUnit - 4.12
  • Maven - 3.5
  • Surefire - 2.22.2
  • 贾夫 - 8

【问题讨论】:

    标签: java maven maven-surefire-plugin


    【解决方案1】:

    maven email group已经回答了这个问题

    达到超时时立即使构建失败

    此功能存在多年: http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#forkedProcessTimeoutInSeconds http://maven.apache.org/surefire/maven-failsafe-plugin/integration-test-mojo.html#forkedProcessTimeoutInSeconds

    当有人按下 jenkins 上的中止按钮时...失败

    这也存在多种选择(在整个 版本)。查看详细页面 http://maven.apache.org/surefire/maven-failsafe-plugin/examples/shutdown.html

    如果您的 Jenkins 将 SIGTERM 信号发送到 Maven 进程(相同 作为 CTRL+C) 则流程管道中的标准输入流变为 关闭并且 EOFException 被分叉的 JVM 捕获并关闭 叫做: http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#shutdown maven.apache.org/surefire/maven-failsafe-plugin/integration-test-mojo.html#shutdown 如果你想杀死JVM,你可以重新配置默认行为。

    如果您的 Jenkins 向 Maven 进程发送 SIGTERM,则启用 流程检查器,请参阅文档中的更多详细信息: http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#enableProcessChecker http://maven.apache.org/surefire/maven-failsafe-plugin/integration-test-mojo.html#enableProcessChecker

    有帮助吗?

    这里是常见问题解答: http://maven.apache.org/surefire/maven-failsafe-plugin/faq.html

    如果您对此主题有任何疑问,请随时提出任何问题。

    如果您使用的是surefire 3.0.0-M4,则可以在target/surefire-reports 中找到线程转储,如here 所述。

    【讨论】:

      猜你喜欢
      • 2015-04-25
      • 2013-05-23
      • 2010-11-26
      • 2013-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-14
      相关资源
      最近更新 更多