Listen to this blog |
Rerunning Cucumber failed scenarios is a great value add for your automation test suites. Sometimes, your scripts may fail because of network latency and test bed slowness. Rerunning scripts will reduce the number of failures.
However, you need to monitor the scripts which are always failing in the first attempt. In this blog article, we will walk you through how to rerun jvm-Cucumber failed scenarios.
Step #1
Configure where you want to store failed scenario details in Runner class
package sample.cukes; import cucumber.api.CucumberOptions; import cucumber.api.testng.AbstractTestNGCucumberTests; @CucumberOptions( features = "src/test/resources/features/Sample.feature", monochrome = true, plugin = { "pretty", "html:target/cucumber-report/single", "json:target/cucumber-report/single/cucumber.json", "rerun:rerun/failed_scenarios.txt"}, glue = {"common","sample"} ) public class SampleCukesTest extends AbstractTestNGCucumberTests {}
Note: Use rerun variable in CucumberOptions to store the failed scenarios.
Step #2
Create a new Runner class to run the failed scenarios.
package sample.cukes; import cucumber.api.CucumberOptions; import cucumber.api.testng.AbstractTestNGCucumberTests; @CucumberOptions( features = {"@rerun/failed_scenarios.txt"}, monochrome = true, plugin = { "pretty", "html:target/cucumber-report/single", "json:target/cucumber-report/single/rerun_cucumber.json"}, glue = {"common","sample"} ) public class FailureRerun extends AbstractTestNGCucumberTests {}
Note: In the ‘features’ variable, you need mention the failed_scenarios.txt file and don’t forget that you must mention ‘@’ symbol before the file path.
If you are running your automated test scripts from Jenkins, you can create and configure a downstream job to run the failed scenarios.
Comments(0)