cucumber re-run failed scenarios automatically with a tag?

大城市里の小女人 提交于 2021-02-06 15:29:49

问题


In our build there are certain scenarios that fail for reasons which are out of our control or take too long to debug properly. Things such asynchronous javascript etc.

Anyway the point is sometimes they work sometimes they don't, so I was thinking it would be nice to add a tag to a scenario such as @rerun_on_failure or @retry which would retry the scenarion X number of times before failing the build.

I understand this is not an ideal solution, but the test is still valuable and we would like to keep it without having the false negatives

The actual test that fails clicks on a link and expects a tracking event to be sent to a server for analytics (via javascript). Sometimes the selenium web-driver loads the next page too fast and the event does not have time to be sent.

Thanks


回答1:


I've been considering writing something like what you're describing, but I found this:

http://web.archive.org/web/20160713013212/http://blog.crowdint.com/2011/08/22/auto-retry-failed-cucumber-tests.html

If you're tired of having to re-kick builds in your CI server because of non deterministic failures, this post is for you.

In a nutshell: he makes a new rake task called cucumber:rerun that uses rerun.txt to retry failed tests. It should be pretty easy to add some looping in there to retry at most 3x (for example).




回答2:


More recent versions of Cucumber have a retry flag

cucumber --retry 2

Will retry tests two times if it fails



来源:https://stackoverflow.com/questions/9833360/cucumber-re-run-failed-scenarios-automatically-with-a-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!