让 Jenkins 运行 自动失败测试

Make Jenkins run failed test automatically

我找到了 Jenkins 的插件 Flaky Test Handler,此插件可以 运行 现场测试,但不会由调度程序自动进行。这个Flaky Test Handler有提供按钮DeFlake Build,但是我要自己点击

问题:我可以在按钮上提出解决方法或任何其他建议吗?

目标是:运行 自动再次失败测试。

您不需要 Jenkins 插件,您可以自动使用 Maven Surefire Plugin for re-run failed tests 的 out-of-the-box 功能,因此作为 Maven 构建的一部分。

来自the official documentation

During development, you may re-run failing tests because they are flaky. To use this feature through Maven surefire, set the rerunFailingTestsCount property to be a value larger than 0. Tests will be run until they pass or the number of reruns has been exhausted.

因此您可以使用以下选项在 Jenkins 上配置 Maven 构建执行:

-Dsurefire.rerunFailingTestsCount=2

请注意官方文档:

NOTE : This feature is supported only for JUnit 4.x.