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
In this post, we are going to learn how to Rerun our failed scenario in Cucumber-Junit Testing Framework. Step 1: In Runner File inside plugin we need to write “rerun:rerun/failed_scenarios. txt”. Cucumber will write the failed scenario and line number in the generated failed_scenarios.
Here is my simple and neat solution. Step 1: Write your cucumber java file as mentioned below with rerun:target/rerun. txt . Cucumber writes the failed scenarios line numbers in rerun.
You enable this via the retry configuration option, like this: In a configuration file { retry: 1 } On the CLI $ cucumber-js --retry 1.
If any of the field say(2nd Object) does not exists in the application, then in cucumber reports the step should be marked as Failed and eventually entire scenario should be reported as failed but the script execution continue to validate the remaining objects(from 3rd object to 10th object).
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With