10 | Cucumber Tutorial | Parallel Execution Using JUnit and Maven Plugins

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign Series so today in this video we are going to see about how to run our cucumber parallel execution by using the J unit okay so in our previous video we have seen how to execute our uh scenarios I mean the features files by using a test ID so in the test NG the Cucumber can be executed in the parallel plugin by setting the Gate of provided parallel option equal to True right so the test NG will will run your scenarios in the parallel for example in the feature file if you have like your four fine scenarios that scenarios can be executed in the parallel mode but when we come to the junit port right so again you can see the Cucumber can be executed in parallel using the J unit and Maven test plugin Maven test exhibition plugin in the J unit feature files done in the parallel rather than the scenarios which means if you use the test NG for the parallel so it is going to run your feature file I mean your scenarios in the parallel board for example in the feature file if you have file scenarios those five scenarios are going to run in a parallel mode when you go for a test engine barely I mean parallel execution but when you use the J unit so the J unit is going to execute the feature file rather than the scenario okay so that is what they have given in the junit feature files are run in parallel rather than the scenarios okay so which means your your feature file is going to run in a parallel mode for example in a project you have a 10 piece of files it it has no dependent on each other cases then it can run in the parallel board okay so that is what we are going to see here the difference is a test NG will run your scenarios in the parallel mode but j in it it will run even future files in the parallel mode okay so now uh we have already created the project so we have a couple of scenario I mean couple of features files so I have created and this is an underclass you have to use so here we have to use the SharePoint Plugin or you can use the maven a fail safe anything is fine okay so we are going to use the name and server plugin to execute our scenario okay so now I have two feature points one is a Google's feature and one is Bing feature okay the Google is going to search on the Google and the link is going to search on the big okay so it will launch the Google browser I mean it will launch the Chrome browser in the Google and it is going to launch the Google browser sorry Chrome browser in the bing.com okay so that is what I just cases we have I mean the features I have designed now and I have the relevant step definitions also being created already okay so now this is the test tunnel which I have created uh this is for you can see this is pointing everything that under the feature file okay I have not I mean pointed to only particular Google feature or Bing feature okay this is I mean uh completely pointing to our features folder which has two feature fine in the inside this feature okay so now when I run this uh it is going to execute one by one so let me run this so first it will run as a bing dot feature because that is what it's on the top okay so if you don't provide any names so by default it will go and sit on the alphabetical order of your feature file so for example if you have ABC order then it is going to sit on the alphabetical order until unless if you don't provide any prefix like a zero one underscore or a underscore something like that why but it will it will store your feature points in the alphabetical order okay and the exhibition also will be going the alphabetical order don't expect the login has to always run on the top okay if you have login uh and if you have application support or application verification something is a picture name then the application feature name Will execute first okay because that will that will come and sit on the top of your feature folders so now we have executed uh you might have noticed the first one we got this Bing search okay and the second one is gone to the Google search Okay so this I mean this particular Runner class that is executing both feature files it is one by one okay now we are going to execute them in the parallel okay so I have only one scenario uh given to the each uh future file uh okay so when we use the J unit it it is it is going to run our future file in the parallel mode not the scenarios okay so test strategy only will run your feature files uh in the scenarios as a parallel board okay for example you have like a four to five scenarios those five scenarios will execute at the parallel mode when we use the test ID okay so we have one common uh runner class which will handle both feature file it will execute the both feature file when you run this one it is going to run execute one by one so we are going to make it as a parallel run so if you go here this is what the main ensure for packing okay that you have to add to your build section in the form.exam so that I have done it here okay so here you can see this is what my build uh plugin I mean build under this build section you have to add this plugin to even form.xml so the result was number one server plugin you can get it from the Google also or you can go to the maven Apache Maven plugin and from there also you can just copy paste okay under the configuration if you see here parallel methods okay method tag will be I mean parallel tag will be the methods okay and use unlimited current also you can have it as a true if you want to control that one also you can control so when you scroll down here you can see if you want to set the platform to specific number then use this as a four okay so for example I want to count I mean I want to control the browser I don't want to go for n number of browser open at the same time I want to control my I mean browsers in the thread so in that case you can see the thread count I go settings the four threads path won't go okay so if you want to uh this to the portraits across all the rows into two points so by default I think it will be uh yeah you can set it as a fault scale okay which means um it it is going to control the thread four threads per one port okay and yeah so we will we will run this see uh this is what the setup now so I have used only the parallel methods I mean the parallel tank set asset method and this gives unlimited uh thread asset too okay now let's go again and additionally we have to include the runner class so I have one Runner class here which is a test Google render dot Java okay so you can give that I mean the complete name also here also for example test Google okay if you have the only one Runner then you can directly give the name like this okay so anything to start in the center like a path we don't want to provide a complete path you can put a starter which will consider as a regular expression to take this particular Point okay so after this uh come here save your power.xml so right click and run as name and test or you can use the name and comment also if you have installed the name but uh Maven in your local computer you can run by your name also that will also be seen the use case okay now it is going to run so it has to launch Google browser as well as I mean Chrome browser one website will go for a Google and another one is okay both are has same use case which is going to search the keyword called sheets okay here you can see this is gone for the B and this is gone for the Google okay it is running in the parallel board so when I run this only this run up I know it is going to execute the feature file one by one okay but when I use this plugin and when I set this parallel equal to methods so it is going to run my future points in the parallel not the scenarios okay so now for example if I go here and if I do uncommon just one more scenario here and here also I am going to uncommon so now if I run no it is going to again my feature file will execute in the parallel board okay so let me run this again see only the two browser is getting open it is not going for the whole browser because we have this feature j in it only the feature level control okay it is not on the scenario level okay so once this is close rn2 browser will open for the external I mean next scenario you can see bring this open so Google is set to open now yeah okay so totally four browser uh which is two times so first time for this particular piece of file and second time for this feature file okay so totally we got four test cases executed I mean you can see it here okay so this is where the test is started and here is the one two I'll be here also two so totally four executed okay so this is how it will execute so I'm going to comment this one okay so this is for the uh I mean method level right so you have another options where you can go and run the multiple Runners so for example if you have multiple targets so in this case we have only one to another okay if you want to have one more Wonder class to manage some other feature file that has no dependence on any any other test cases or any other feature file then we can have it as a multiple Runner classes also so in that case instead of parallel equal to methods you have to set it as the age of class and methods or class okay so this will be zero so what I'm going to do I'm going to duplicate this one I'm going to create one more Runner class so by the name out so this one I'm just giving as a test Runner or two okay and I'm going to give this name as test one run okay so now I have a two runner class so two runner class also it's going to do the same thing okay we are just copy pasted things so it is going to run all the two feature points one by one when you run it as a individual way but uh here right so since we have made the changes so I am going to remove this complete file name I am going to have as a regular expression to pick anything that the faster under classes okay so now it has to run two runner classes so in this case instead of methods we have to provide us a class and methods okay now it is going to run so now we it is it is going to run on the runner level okay so now I'm going to run this yeah you can see so totally four browsers got open now so all the flow four browsers are I mean having some tests being executed now so which means so earlier it was only two cases I mean two browsers were opening and it is doing the execute right now it is coming as a four because we are running the the runner itself in the padlet okay so this Runner also has two pieces files and this Runner also has two visa file so since we have given the parallel equal to class and Method it is going to run them our our tests are in the parallel board so which has every every Runner has two feature files okay so that's the reason it got two four browser at the same time okay so when we use the only one block I mean only one Runner so that has a two feature so it was running as a tote browser when I go for a two runner class two into two it is it is getting open in the fourth browser okay so this is how we have to do the uh or achieve the parallel execution by using the J unit with the maven test execution packet okay so again uh point to remember in the sense so our j in it will execute the feature points in the parallel board but when you go for a test energy the test engine will execute your scenarios in the parallel okay so that's the difference we have to remember so you have multiple Runners yeah you can have the multiple Runners also you can run the parallel board so in that case it is going to run so this this Runner has two piece of Pi so that is getting open at the same time and this Runner also have the same feature file and it has it is it is getting open the two browser at the same time so totally four browser is opening for this particular use case when we have the multiple runners okay so now again you can go to the terminal uh so here also you can use the maven command to execute the things I mean to execute your run so just go to the terminal if you have Maven installed so may even clean test the command you can use on mavenclean verify also you can use so now again this we are running the multiple Runner classes it has to launch four browsers in the same time two browsers will run a run on the Google under two browsers should have the bing.com let's see here so first I mean totally we have four here so two being now we have 2B and two Google browser I mean Google website okay so this is how it will work and everything is working fine you can see everywhere it is it has started typing the cheese keyword all the browser has the values I mean the keyword that we have sent us the cheese is getting entered in the Google search till it is running yeah once is done you can see here so we got I mean everything got executed so here you can see the I mean there are some 10 years it's also because of that assessment is getting paid you can see so this failure is because of the assertion uh on the title page uh it is it is filed okay that is okay that is expected one okay everything is working fine so this is how we have to do the parallel execution in the J unit 4 okay you have to have I mean um you can create a number of feature files in the picture files you have to provide I mean in the pump.xml you have to add this button to run your feature files uh in the parallel mode if you provide us a method then uh it will exude one Runner class uh with a different feature file when you have the multiple Runner class then you can go for the Instagram method you can provide as a class and methods or you can use the class okay in addition to the methods okay so that's all about this video This is how we can achieve the panelism parallel exhibition in the Cucumber by using the JL so we'll see the next Topic in the next video thank you guys
Info
Channel: Saravanan Seenivasan
Views: 10,107
Rating: undefined out of 5
Keywords: cucumber bdd, cucumber BDD framework, cucumber data tables, how to read the list values from cucumber feature file, how to pass the list values in step definitions, cucumber saravanan seenivasan, qa learn together, cucumber tutorial, cucumber parallel, cucumber parallel execution, cucumber parallel testng, cucumber running parallel test, testng cucumber parallel, cucumber junit parallel, cucumber parallel maven, maven cucumber parallel, maven pom cucumber parallel
Id: hpdGZU_r51c
Channel Id: undefined
Length: 15min 31sec (931 seconds)
Published: Wed Feb 15 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.