'cucumber re-run failed scenarios automatically with a tag?

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



Solution 1:[1]

More recent versions of Cucumber have a retry flag

cucumber --retry 2

Will retry tests two times if it fails

Solution 2:[2]

For cucumber + java on maven i found this command: mvn clean test -Dsurefire.rerunFailingTestsCount=2
, u must have actual version of surefire plugin, my is 3.0.0-M5. And nothing else special u even need.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cyril Duchon-Doris
Solution 2 Ivan Artuhin