PART 8 - Rerun Failure #SCENARIOS in Cucumber BDD

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys this is navini welcome back to naveen automation labs and back to our cucumber series today's topic about how to re-run the failure test cases slightly different as compared to test energy we don't need to provide any listener or any predefined listener which will keep listening uh the failure test cases and then we don't need to apply any retrial logic for that uh testing you provide one a plugin for that that is called a rerun plugin so what you just need to do that go to your runner file so let's see this is our parallel run dot java that we have created doesn't matter you are using test ng or junit they provide one plugin over here so in the plugin section put a comma in double quotes you simply write one plugin that is called rerun plugin and what exactly it does it will generate one rerun.txt file that you have to generate i mean name can be anything so let's see i want to generate a dot txt file under my target folder it means in this particular target folder you can give any folder name that doesn't matter and then i'm giving let's see my file name is failed rerun dot txt whatever the name you want to give you can give that so i simply write let's see failed rerun dot txt file everything is in a small head and that's it after that what exactly it will do it will generate this particular txt file if any scenario is getting failed it will make an entry of that particular scenario in this dot txt file then what you have to do you have to create one more runner file which will we have to make the entry of this txt file in that runner file and then we have to execute that runner file once again so that we will do it in some time but let's execute this runner and what exactly we will do we will make one test case deliberately failed so i'll go to my login page and let's assume that okay this is the buy dot link text forward password one one one so obviously this is a wrong locator this will be failed it means one test case will be failed and if i go to my feature file where a scenario is written at line number eight this scenario will be failed right so go to your parallel learn.java and execute this particular feature file from this section and let's see this is a runner i mean this failure.txt file is getting generated or not so run as testng and uh let's see so we are already running in the parallel mode three chrome browsers are running in the parallel mode one will be failed so it is almost done very straightforward and done so you can see that okay one test case will be failed in the test ng result also you can see the forgot password got failed and the console also if you see that we have one failure is available here so one fail which is the no such element exception for the forgot password perfect forgot password link is not available now what we have to do we will refresh the project and inside our target folder we will see failed dot txt got generated and now see this file it will give you that inside this particular login feature this is a file colon tag under this particular uh login dot feature file scenario number eight i mean scenario scenario which is available at line number eight sorry got failed so it's you can see that at line number eight this particular scenario got failed actually right now what we have do with the help of this dot txt file we have to create one more runner over here so in the parallel i'm going to create one more uh i would create a class and then let's see i simply say that is my failed runner a failed run whatever the name you want to give and click on finish and whatever you have in your parallel run exactly same cucumber options i'll be using it copy this and you simply paste it over here sorry on top of the class name here and after that inside the failed run what you have to you have to um add those things as well that is override if you really want to execute all the failure test cases in the panel run that also you can do that so that should be like this and then remove this re-run over here from here what you just need to do uh the plug-in pretty and all those things will remain same remove this guy now rerun simple right that is i want to rerun which file my target failed runner.txt file and what is the file name the file name is once again we have to tell where exactly the failed runner is available the failed runner is available under target folder so you have to write at the right target so do not forget to write at the red target and then you simple write this particular file name once again dot txt right and then we have to extend for the parallel run if you really want to extend this abstract testing gq test also you remember we use that we have to use that as well and import this particular okay then error is gone like this now let's see this in failedrun.txt we have one failure at line number eight only that failure it means the forgot password link should be executed once again so what i'm okay that is a failed rerun actually guys we have to give sorry about that let's run it again and let's see now see it's picking the scenario for god password awesome and then again it will be failed obviously because it's not fixed and then again getting failed so this is how we can execute the failure test cases but as such we don't have any retry counter that how many times we want to execute again and again now let's do one thing now deliberately i'll make a couple of other test cases failed let's see submit login when you click on the login button that is also getting failed so it means two test cases should be failed it means when you click on the login button this particular step will be failed it means the scenario also will be failed and the forgot password also will be failed so line number eight and line number 13 these two scenarios should be entered in this particular failed rerun.txt file so first you execute this guy and let's see what happens so out of three test cases two test cases will be failed so they are running in the parallel mode that's fine so done and you go to your failed run.txt can you see that scenario which is available at line number eight and line number twelve both got failed see this that is what exactly i told you right eight and twelve both got failed if this is also getting paid it will make an entry 3 8 12 like this and then you run your failed run.txt once again and simple re-run it so second time also it will be failed because we haven't fixed it so you can see that only two test cases are running forgot password and the second one is the uh the second one is the second one is the login one you can see the result over here uh login with the credentials and forgot password they both got failed so what is the advantage of this the advantage is that let's see by mistake any any network issue or i mean some problem is there on application is not serving properly or or there is a glitch in the application that element could not be found or something like this by chance if any scenario is getting failed that will make an entry inside this particular.txt file and then you can execute this txt file once again just like in sng we have this failed a testing geo.xml file and then we can rerun it similar kind of stuff mechanism they are also using it so with the help of this rerun plugin guys you can do that so it's pretty simple so when you integrate with let's see some ci cd pipeline what you do the the next upgrade uh upstream pipeline up steam job in the pipeline you can create for the failedrun.txt this failedrun.java file you can execute that which is having failedrun.txt so first execute this paralleldon.java it will generate this.txt and then execute this failedrun.java which will execute the failure test cases once again in your csd pipeline with the help of jenkins you can do that okay so that's all for this particular video this is how we can do that there are some other third party solutions also that i don't want to cover i'm not sure how reliable they are but this is a feature which is available in test in cucumber directly so that's what we can use that remember this rerun plugin you have to use that for failure test cases execution so that's all for this particular video guys thank you so much thank you so much guys thanks for watching naveen automation labs
Info
Channel: Naveen AutomationLabs
Views: 14,943
Rating: undefined out of 5
Keywords: cucumber rerun failure test cases, failure test cases in cucumber bdd, retry logic in cucumber bdd, cucumber BDD videos, cucumber with selenium, cucumber BDD page object model, Naveen AutomationLabs
Id: 3BBxrDblEWc
Channel Id: undefined
Length: 9min 25sec (565 seconds)
Published: Thu Jan 14 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.