如果它们失败,请重新运行不稳定的JUnit测试
我在詹金斯(Jenkins)有一个作业A,用于自动化测试,如果另一个作业B构建成功,则会触发该作业.作业A运行了几个测试.有些测试很不稳定,所以我想再次运行几次,让它们有通过的机会,这样我的构建就不会不稳定/失败.
I have a job A in Jenkins for my automated testing that is triggered if another job B build is successful. The job A run several tests. Some of the test are flaky so I would like to run them again few times and let them the chance to pass so my build won't be unstable/failed.
我可以使用任何插件吗?
Is there any plugin I can use?
我建议修复或重写测试,以使它们仅在发生故障时才会失败.也许您可以嘲笑那些可能会失败的事情.如果您要终止数据库连接,则可以使用本地的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.
If you want to rerun tests in JUnit-context, take a look here: SO: How to Re-run failed JUnit tests immediately?