Retry/Rerun Failed Scenario in Cucumber Junit FrameWork

Retry/Rerun Failed Scenario in Cucumber Junit FrameWork

In this post, we are going to learn how to automatically retry our failed scenario in Cucumber-Junit Testing Framework. For this purpose, we have to use Extended Cucumber Runner which is basically an extension of Junit Standard Cucumber.

Step 1: We need to download Cucumber-Runner maven dependency or Jar from this link. In this blog, I am using the below maven dependency.

Step 2: In Runner File now instead of @RunWith(Cucumber.class) we need to use @RunWith(ExtendedCucumber.class) along with ExtendedCucumberOptions.

Now once any of our scenarios will get failed Extended Cucumber Runner with automatically try to Rerun those failed scenarios number of times we have specified in RetryCount under ExtendedCucumberOptions.



My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
November 11, 2019 at 9:14 PM

Hi Ankur,
Thanks for this tutorial. I tried your approach, but facing an issue with Cucumber higher versions. Seems to be, Cucumber extended options are not compatible with higher versions of cucumber. Is there any way to make it work with higher versions?

June 14, 2021 at 6:54 PM

tried above but getting exception

cucumber.runtime.CucumberException: No backends were found. Please make sure you have a backend module on your CLASSPATH.