Running Cucumber Tests using Maven (Cucumber BDD - Part 37)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello all welcome to part 37 of cucumber vgd training Series in this session I am going to explain and practically demonstrate how to run cucumber tests using Maven so let's get started till the previous sessions we are running the Cucumber test using the runner class where the runner class is invoking the feature files and feature files are invoking the step definitions right but in this session I am going to show you how to run the Cucumber test in this Maven project using maven so let's switch to the Practical mode now so here you can see the runner class guys which is actually invoking the feature files under this feature features package and once this Runner class invokes with the help of junit we are running actually okay with the help of j in it we are running the test okay J unit is invoking this feature files using the Via this Runner class and feature files are invoking the step definition files and step definition files are invoking the implemented methods inside them for each and every step of this feature files okay that's how the tests are running so far but what I'm going to teach you now is or practically show you now is okay how to use maven to run this test instead of junit and all okay generator run a class so further guys I'll right click on this project and select run as option and when you say run as option we'll get all this maven options here okay so why we are getting this Maven options in Eclipse ID by default Maven plugin is already installed we don't have to separately install okay in the latest versions of eclipse ID Maven plugin comes by default yes okay so that's the reason when you right click on this project and select run as you'll get name and options also okay in Eclipse ID now I need to select this name and test okay not to run this uh test in the project with the help of Maven I have to select this right click on the project run as and select name and test but unfortunately when I select the option the desk will not run we will see that none of these feature file scenarios will run now you'll see that okay just wait so it says build success but did you see any uh feature files in as running no right they have not run so it's a problem the problem is there are few rules okay if you want to run this project with the help of Maven and run the test in this project with the help of me when there are a few rules that is uh whatever the files Java files that you want to run with help of maven should be having a test keyword either at the beginning of the Java file or at the end of the Java file name okay so for example if you want to run this login.java okay then test keyword should be there before the login or either after the login okay similarly okay so there are four Java files here as you can see in this project we have my runner.java we have login.java register.java and such dot Java test keyword should be there either at the beginning or ending of this file names but here to run all this to invoke all these feature files which Java file we are using myrana.java file we are using so if you update this name of this my Runner 2 either test my Runner or my Runner test or whatever it is okay add the test keyword okay instead of my just put test that's also fine okay test Runner or Runner test whatever you want to do okay just rename this uh class guys okay class name here instead of Mile right test run okay so if the Java file name doesn't have this keyword either at the beginning or ending of the test maybe we will not be able to identify guys okay so hover the modes on this test Runner and rename the file to test runner.java you can even put this test keyword after the runner also that also will work okay now simply I'm putting the test keyword at the beginning uh the naming looks good test Runner okay or I'm not test any name you can give that's all that's okay until we have this test keyword in the beginning and ending of the file class file in so here also the file name version to test run whatever the class we mentioned the file name also got changed it to test Runner now I simply right click this time and one more rule is there okay first rule is uh you see you should have the uh this uh whatever the classes should run right the class should have the test as a keyword second rule is that go to com.xml file since we have created this project with the help of uh we have created this Maven project by using uh Maven quick start Maven architect Kickstart uh template so all these things have come by default most of the things in this form.xml XML file have come by default including this uh this build and plugin section okay plugin section in the plugin section under the plugins there should be Maven shoot file plugin available okay if not Marin will not be able to run this uh required Java file having the disk keyword okay so here you see there is something like Maven sure file plugin okay there's a maven Shield file plugin so if this is not there in your plugins section of your palm.xml file you have to add it guys okay you can get it from online guys just search Maven shows our plugin you will okay you can get it from online okay maven Ed by plugin just search it online guys and uh just go to this website and uh scroll down if you're not getting anything uh just go to other one let's see what is there here this is uh ambient repository that's okay um okay I'll say I'll just click on this now it's coming uh the moment I added this com keyword so this may mentioned my plugin I'm getting this different examples because usage page is coming in the usage page as you can see you see you can copy this part okay when copy this part guys okay if you don't have this uh plugin in your form.xml file you can copy from here that's okay again copy from here okay so fine once you have this Maven Surefire plugin in the uh inside the uh what you call other builds okay plugin section of this form.xml file okay once you have that do one thing right click on this project and select run as Maven test okay this time it should run okay this time we have the test keyword in the runner class only the Java file is having the test keyword will be running in the beginning or ending will be running at this login register and such will be indirectly invoked okay because Runner class will invoke the feature files feature files will remove the script definition classes step definition classes will see tests are running you see here if you are getting this test option and uh you see earlier only we got a build successful and all but this time we got test and running the test test Runner okay test Runner has run okay runda.testinal has run with the help of maven because we have named the Java file to test Runners Java file to test Runner okay and once you run it you see all the others all these things got uh you know so here it is clearly saying this one is called 14 14 tests okay from all these feature files 14 scenarios from all these feature files have run with the help of Maven guys so hopefully you understood how to run the test uh the Cucumber projects using Maven okay in this session so that's all for this session see you gonna session thank you bye
Info
Channel: QAFox
Views: 4,305
Rating: undefined out of 5
Keywords: Running Cucumber Tests using Maven, Cucumber BDD Made Easy, Cucumber BDD Tutorial, Cucumber BDD for Testers, Software Testing, Software Testers
Id: FI2WgDVIkvk
Channel Id: undefined
Length: 7min 24sec (444 seconds)
Published: Fri Dec 30 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.