且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如果它们失败,请重新运行不稳定的JUnit测试

更新时间:2023-11-19 23:31:16

我建议修复或重写测试,以使它们仅在发生故障时才会失败.也许您可以嘲笑那些可能会失败的事情.如果您要终止数据库连接,则可以使用本地的sqlite或smething.

I would suggest to fix your tests or rewrite them so they will only fail if something is broken. Maybe you can mock away the things that tend to fail. If you are depnending on a database connection, maybe you could use a sqlite or smething which is local.

但是还有一个可以重试构建的插件: https://wiki.jenkins-ci.org/display/JENKINS/Naginator+插件

But there is also a plugin which can retry a build: https://wiki.jenkins-ci.org/display/JENKINS/Naginator+Plugin

只需安装插件,然后在项目的配置页面上检查生成后尝试重试构建"操作.

Simply install the plugin, and then check the Post-Build action "Retry build after failure" on your project's configuration page.

如果要在JUnit上下文中重新运行测试,请在此处查看:

If you want to rerun tests in JUnit-context, take a look here: SO: How to Re-run failed JUnit tests immediately?