Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 707
amleszk Avatar asked Mar 23 '12 02:03

amleszk


People also ask

How do you rerun the failed scenarios using Cucumber automatically?

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.

How can we rerun failed test cases in Cucumber?

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.

How do you add retry to cucumbers?

You enable this via the retry configuration option, like this: In a configuration file { retry: 1 } On the CLI $ cucumber-js --retry 1.

How do cucumbers fail scenarios?

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).


1 Answers

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).

like image 167
neomindryan Avatar answered Oct 08 '22 11:10

neomindryan