How to run Cucumber Tests with Maven | Override Cucumber Runner Tags From Maven Command Line

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone this is smothie welcome to Q automation classes so in the last class uh we have seen the uh scenarios right so we have seen the different things like how to uh put your common steps into the background right and in today's uh class we're going to look into the uh cucumber Runner right so we used to execute our test through the Cucumber Runner right if you see we go and we run the cumber test Runner but let's implement the running the scps are the Cucumber Runner through the command line argument of the mavin right so for that what we need to do so let's go to the Cucumber Runner first okay where is the cucumba runner okay cucumber test Runner so we have given the feature file location okay so feature file location is there uh glue equals to St definition right okay everything is there and TX perfect so now uh okay so everything is there so let's create the Marin configuration so let's say edit configurations okay so let's go to m okay and uh here let's say BD selenium framework okay M CMD okay command line argument okay let's say something uh let's just say m Run Okay M run okay and command what command we going to give we're going to give the command as clean and test okay so this is the command line we're going to give and uh working directory is B selenium framework we don't have to do any profile as of now that is perfectly all right so now we can go and start running it let's see if it is working or not apply and okay and let's run the MAV run and let's see if it is working or not okay so some problem encountered while building the effective model okay that is fine so now if you see what happened here okay so it is saying uh the build is Success okay so we said clean and test right so edit configuration and say clean test but Our intention was to see the runner right so running uh the test Runner but test Runner is not getting picked up here right you see it is just going and downloading some dependencies here downloading and then here if you see right so the messages okay build success but no execution happened okay and there are some problem encounter while building the artifactory model building the effective model okay so we'll do one thing okay so there are AUM Java duplicate version okay fine okay so let's uh try to make some changes here so that uh we can run it from the M configuration so what are the changes we need to do so first thing is let's move all our features right under Source test resources so can see the features okay let's move it under Source test resources okay perfect refector delete from get don't ask again no we don't want to delete right okay did it come here let's first see first features okay it came right okay so okay open login page. feature user login. feature so the features are moved under the resources so now uh we have to update it in the runner also so Source taste and uh then you say resources okay resources okay resources SL features okay resources SL features okay this is fine and uh let's try to run now okay let's see if it is working or not let's run okay so again the same thing right it is saying the build success but it is not picking up okay and there is some issue with this dependency we can look at this okay must be unique what is this IO cucumber cucumber Java jar okay cucumber Java jar let's go and see I cumber cumber Java maybe I have added it multiple times what doesn't find it okay let's see cum. Java IO cumber Java 7.15 I cumber Java 7.15 the same version I have added two times okay fine we can do one thing we can put this i. cumber cumber Java 7.5 okay so let's comment it code comment with block comment okay fine I cumber Java 7.15 I cumber cumber Java 7.15 okay fine so now let's try to run and see whether this time it is going to get picked up or not till now looks good okay so now it is say it ran but build success but it didn't even pick that Runner right so there is one more thing we need to do okay so while the runner is not getting picked up so we need to rename the runner class and we should end it with something called tast okay so what is the Cucumber test Runner okay so let's refactor it and let's rename okay ref Factor Why the option is not coming okay ref Factor Why can't I see this okay I think I need to refresh it once okay let me check cumber test Runner ref Factor okay so let's see so after refreshing so let's right click and you say refactor rename file okay so instead of cucumber test Runner let say cucumber Runner test something like this we can say Okay cucumber Runner test Java Okay so nowor okay so now if you see cucumber Runner test okay so let's go to the MAV run and try to run this time and see what happens okay so starting class Kumar test Runner is public should be declared in a file name okay so we have to rename the uh this one also right cumar Runner test the class name my bad okay fine so now let's see save it and run it in it ISO run it okay this is what I wanted to see see so now it is going to pick up it is going to pick up the runner class okay so running test runner. cumber Runner test right and now this cucumba Runner test is getting picked up and this cucumber Runner test knows where exactly the feature file is located right and uh it will go to this feature file we have as of now we have as of now we have one right and in the runner also we have tags as all and this all tag is applied at the uh if you see feature level right so all the uh scenarios that are defined inside this feature are going to get executed right so in mavin run you can see this is a mavin run this is the snapshot there are test failers okay that is fine so because of this uh this invalid ones right so negative scenario and one because of that it is uh saying that are test failes okay so mavin run you can see here right so where is the fail this is assertion error right because of that ke automation invalid username and invalid password okay so Our intention was to uh inoke the cumber Runner right through the uh mavin command line right so that we are able to do through this one okay so this is how there are two changes you need to do you have to push all your features inside the source test resources right and one more thing your Runner should end with test right cumber Runner test so whatever name you give that should uh end with the test and then in the M run configuration you go and say okay clean test okay then it will run so this is one thing okay and uh if you have remember I have already told you right uh last time also when we're uh learning about the tags so every time coming to this section and updating this tag is really impossible right when your code is in the bit bucket or git lab right in the uh source code uh repository management source code management system or the remote repository in that time what happens uh the code is already pushed there right so you cannot go and make the changes right you have to to uh create the jobs out of it right so how will you create those jobs out of it so for that one we can pass the whatever tax you want to run from the command line itself right so let's understand that on how to do that okay so now you see I'm saying tax equals to let's say I'll change it to smoke or something okay unless I'm changing it to smoke so that means what only the smoke tag is going to get executed so here if you see only one tag is one scenario is with the smoke right pass test inline so now I'll override it okay override and from the m command line I'll will pass something right so let's see clean test what is the Run configuration so edit configuration so you have clean test so after clean test you say hyen d okay so hypen D you have seen right in the uh tdd style of the development also to pass the parameters so now you say cucumber dot okay let's say filter cucumber. filter and Dot TX okay do tax equals to and you pass here the TX at the rate our tag is let's say regression so I want to run the regression okay but there in the runner I have smoke but I want to run the regression okay so now say apply so just verify this one one more time clean test hypen d right so hyen D is for here you should give a space okay space hypen D cucumber. filter. tax equals to at theate regression okay so now let's apply okay and you can run from here okay so my expectation is so this one should get executed right regression one let's see what is getting involved here so it's building okay let's see this is for negative invalid data okay okay good so now let's see okay so if you see here there are test failures that is perfectly all right we we know that so let's see so what happened so which one got picked up here right so if you see here right uh running test runner. cumber rner test and at the rate all at the rate regression at the rate positive login scenario okay so these three because if you see at the rate all right so this is at the feature level so this one also displayed here right and then at the rate regression so if you see at theate regression because we are trying to run this regression right so that particular tag is also picked up and then we have the examples here right examples is also Tagged so that tag is also shown here similarly one more we'll see at theate all at theate regression at theate negative scen login scenario right so if we say at theate all at the rate regression at theate negative login scenario which got failed over here right so this is how you can pass the tags from your command line right so for the M command you can override whatever the tag is defined at your Runner level you can override it by passing it from the command line Okay so yeah so that's all guys so if you guys are really enjoying these sessions I'll request you to subscribe to my channel Q automation classes and stay tuned to the channel for the upcoming videos and uh please do share this with your friends and colleagues so that they can also get benefited out of it and uh if you have any questions or comment or any suggestion or ideas you can ping them or put them in the comment section I'll get back to you as soon as possible so yeah stay tuned to qy automation classes for the next sessions thank you everyone bye-bye have a good day
Info
Channel: QA Automation Classes
Views: 149
Rating: undefined out of 5
Keywords: cucumber, maven, cucumber maven command line, maven cucumber reporting plugin, how to run cucumber tests with maven, how to run bdd cucumber test with maven command, running cucumber tests using maven, maven cucumber, cucumber bdd, cucumber bdd made easy, maven cucumber report, cucumber tags maven, cucumber maven test, cucumber jars maven, maven cucumber parallel, cucumber dependency in maven, maven cucumber reporting, execute cucumber command line
Id: 98Ss_pVXdQ0
Channel Id: undefined
Length: 12min 37sec (757 seconds)
Published: Mon Apr 29 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.