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.txt
file.
Step 2: We Need to Create another Runner File. Let’s
Name it as ReRunRunner.Java and inside feature we need to provide the name
of this failed_scenario.txt file along with @.
Now once any of our scenarios will get failed this failed_scenarios.txt the file will be generated inside the rerun folder with failed feature file name and
using the ReRunner.Java file created in Step 2 we can easily rerun our failed scenario in
Cucumber-Junit.
There are some problem in this code such as:
Reply1. The scenario name it is not mentioning in the . txt file.
2. After Rerun the file is not getting deleted even if the scenarios got pass after Rerun.
3. It's not getting executed automatically. We need to manually run the rerun. Java file to get it executed.
Please suggest if you have any solutions to the above.
Hi Ranjan,
Reply1) scenarios names are getting displayed in .txt file I have also attached screenshot for that.
2) This functionality is built in the same line as testng-failed.xml file.This is something I can't control.
3) The purpose of this blog is to showcase how to automatically get the list of failed scenario again this is in line with TestNg architecture.
For automtocally rerunning this there is another article on the blog which you can refer.
can you share the .txt file and let me know where it would be added...
ReplyThanks
Sumanth
Can you share the blog link where it is mentioned how to automatically rerun the Rerunner class?
ReplyThe title says about automatically re-running the tests...
Replyhow to run the failed scenario using reRunner file on Jenkins
ReplyHow to re run automatically?
ReplyHello.I follow your guide, i have the failed scenarios in the txt file, but in the second run instead of running the fail scenarios, run all the scenarios again.
ReplyAny idea?