Testng Tutorial for Beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey hi bro welcome back to learn - Automation calm this is Mukesh so this is my first video of 2017 and today we will be talking about testing G tutorials so I have created some of the videos long back but in different like parts but today I will start with the starting guide how to start with tests in the end we will see some of the basics today so let's get started with high level agenda so in this video we will be talking about what is test and your framework what is the advantage of testing to brainwork how to install it a stingy if you are using eclipse and how to create your first script using piston G how you can creat your multiple test cases using tests in G and we will also see Auto generated XML file so once you run your first sales case you will get one automated or Auto generated XML so we'll see how to read this and we'll also see the default report which is generated by testing G test indeed very good tool or I will not say to Ilse framework so you can take so many advantage of this framework so in this video I will be talking about very less number of features but once you move forward we'll talk about almost all the features they have given so far so if you talk about what is stress in G and it's the last one we will be adding some more details to the test cases so test in G is just a framework and if you talk about the full form test range is 10 for testing next generation so it's a unit testing framework so developer used previously g-unit so Jane it is mainly for unit testing which mostly used by the developers by testing G is again you can say additional framework which is inspired from J in it so all the features which you have in James you will find in the testing Jessel so how to use it and what is the reason of using it you will get to know in few minutes so that when you have multiple flashes interfaces methods which will make our talk easy so soon you will get to know we need to write so much of code to generate reports and to perform sequencing but intestine he has these default features you can take advantage of the inbuilt method so we will be using a couple of them today destiny provides so many additional functionality so that you can create your through those framework itself so if you start writing your own code from scratch will take a lot of time so better to use someone else or impose which is already developed and it's quite stable as well there are some open issues with test engine but that is ignore bill you can ignore all that because in what that you will not get effect in your test execution okay so what are the advantage you will get once we start working with us in G so I have taken all this advantage from their official website but I have customized little bit based on my experience so you will get the default reporting you don't have to write a single line of code to generate reports you can directly refresh your project and you will see different kind of reports that is auto-generated different kind of annotations if you want to control the test execution then you have multiple annotations which I will show you in few videos and in this video as well so you can control the complete execution how you want to run the test and so on so what are the notation I will show you because of not under taejun's you can say I started to add that it symbol and we use some of the classes with annotations so you can run your tests in arbitrary big thread pools it's quite tactical sentence so let me make it simpler so let's say let's say you have more than 50 test cases and now you want to run them in a specific order or based on a certain requirement you want to an only set of tests then testing we will provide you one easy way using tests in G dot XML files so that you can select a specific set of test cases or a specific scenarios you can execute it's related to the third point of easy and flexible test configuration you don't have to write code for this there's one XML file in this simply need to modify that XML file and that XML file is also also you can generate using nucleus you don't have to start from the scratch Nicholas will make your task easy we will be integrating one test in your plugin and that second you can generate that XML too so I have already uploaded from video and data driven testing using selenium so I used to change easier itself so using testing you can create data-driven frameworks and you can use this data provided annotation support for parameters if you want to run your tests based on the parameters so definitely supports parameter feature so this parameter feature will make your test cases or test suite very flexible you can pass the parameter at runtime so that based on the requirement you can pass the parameter and you don't have to modify your existing test easy way to execute a switch so you have multiple classes to execute this test suite or else you can directly right click and you can turn the complete test suite yes this is very important it supports multiple IDE so I am using eclipses of stock but you can use NetBeans you can use IntelliJ you can use webstorm and grouping features so you can group your test cases let's say you have four categories smokes recreation functional non-functional and twenty can group all the test cases and you can run them individually and there's so many features so I will be giving you one link in the description so that we'll be testing your official link so you can go through it but anyways I will be covering in the future videos so let's get started I have this project created right now this project is completely blank I have only one source folder so let me show you how you can install the send if you have not in your Eclipse so just go to this help section and just click on this Eclipse marketplace so it lists marketplace is similar to place tool where you have all the existing plugins so you can select which plug-in you want and you can start using it you can see there four or five tabs search the same popular rivet is installed so if I go to the installed one I already have in my Eclipse so it will be coming under installed but for you if you do not have you just click on the search option and search for tests in G and hit enter it will take some time to come up with the search result so in my system it's already installed so I will be getting to option and install and update but in your case you will get one install option you just have to click on it and it will install that you can see it's already installed right and if you want more info you can click on more info and it will give you all the details so my system is little bit slow if you can see now you could click on more info you can learn so much about test in G so as of now once installed you can click on cancel in your case if you click on install it will ask you to restart your Eclipse and G cyst you have to restart your Eclipse this is just additional detail which is coming from eclipse that's fine you can close it so now let's create our first test so what you need to do you need to just right-click and create a package and I will save first or I will say test in G tutorial so this is a default package which I created now I will create a first class so you can see you can create directly from here as well but I will show you with Java so I will same first just in G script so till now we have used this publish static void main but this time we will ignore this public static void mean we will also we will write our own test cases so let s say the member will run over test until now gave him was running over test but today the stingy will run over test so let me increase the fontsize respect to show you one minute so in Mack there some different settings or any to check that's fine so I will write my first test so I will write here test one and or maybe I can write log in application so I can see this is just a method which I created so if a completely new to Java you can visit my previous tutorials where I have discussed what is method how to create methods method overloading to work with test range you have two simple right one at the root symbol and just paste test chip so when you type test Eclipse will ask you what is this test so now you can see right now it is giving one suggestion only for J unit because J units comes by default with Java project but now we will click on this ad test in G library so when you add testing library this library will get added to your project and if you expand this you can see couple of jars has been added so most of the time you will be using this test in G dot jar file and if you expand this as well you will find so many packages so will use some of them today and once you move forward will use almost all so as of not just yes calab this now you can see not is still asking you which test you want to import now we have option of testing G as well so just click on testing G and you can see here when import statement appeared and it is actually coming from this package and this is the class so test is a class and you can see we are getting some default description as well and you can see it's very old tool initially it started by Cedric in 2004 and we are using in 2017 design so this is our first test and if you want to see from where this package is coming so just check OLG dot position G dot annotation if you expand it and if you try to search for this package it is coming from here you can see osg dr. string G dot annotation and if you see here dot oh yes so this is the class so if somebody is asking or if you get this question in entry what does exactly this test so test is nothing but a class in test in G so we are going to use that class to create these cases now as of now just for getting started I will just write one hello one two statement and I will write hey this is my first now if you want to run this test so you have multiple options so in Java we just do right click run as java application but since we are not using publish static void main now you will get this option test in G test and why this option is coming because we have added testing G right just right click on this run is substantiated and now you will see the magic so first of all you are getting this console window symptoms whole window you can see it is running one internal XML file right I will show you in just a few minutes this is the hello world statement or first statement that we return right hello this is my first test so this is the console window which we are getting in Java as well and you can see now you have at least some status like whether this response of a so log in applications nothing but the test case name so whatever method you have written it will be come out case and this is status so you can see there are two sections are coming one is Test section and when it's a default suite so the false we will talk once we have multiple test cases as of now you can see here only one executed and zero failures it is skipped now if you see you will get another section here so you can see there one pass zero failure zero skip and this is a hierarchy which you need to follow so as of now you can just check this test in his tutorial test in G tutorials nothing but of a package that we created first test in this script is our class and this is your test cases terms of no only one test if you want to run multiple tests you don't have to create a separate each our class you can copy page and you can create another test case so after login I can say select item arrival rate login to application as of now I'm just writing this this out statement but our but once it starts working with selenium we will write our actual code in this and I will say item selected and let us say I want to add one more test once items are selected I want to check out now if you right click and run as the stingy test you will see it will run three test cases so you can see check out one second is login application and the third one is select item I know you must be wondering why it is running and then in random order right because previously we had given login then select item then checkout but it is running in different order first it is running check out and then login application and select item so this is interview question if you do not mention the order or if it is not specify the orders by default satsangi will run based on the alphabetic order right so you can see see comes first so it is execute executing check out first then L Comfort is running login application and finally it's running select item so technology have this features you want to run them in a specific order we can assign a priority that I will show you but as I saw you can see in just one Java class we have created three test cases and all are running individually now just come back to this console window and you can see here all three tests passed here is the countess added but we have one more information here so you can see when it runs it runs one test ng customized sweet dot XML file so it runs internally so you don't have modify this but just for your information and you might get this question in interviews as well so let's open this XML file so that we get to know what exactly is executed by test ng so when I opened that XML file if you are working with Windows you can just open through run command or you can go to that particular location so this is my XML file which is internally executed by distant G let me increase the font size so you can see this is the default one you don't have to worry about it the main thing is start from here right now it is creating one XML file this XML file is auto-generated and you can see here we have some virtual text so we have one sweet tag so sweet egg is started and ended here so whatever name you will write here it will appear on the screen so as of now we have not given any sweet name so by default test ng will assign default three so that is the reason if you go back to this you will get default three right because it is internally assigned by test in G so sweet is just a tag but actual tests which starts from here so your again test suite is default test so you can see default set system in rest already we have decided so this is one internal XML which is created by testing soon will be create our own XML so you will see we will give very meaningful name for our test feed so that whenever we go back we can understand which kind of tests which we have created and which kind of test cases we have so this is just additional of no uses of snow but in case if you are getting this question in interviews you can reply easily right so now we have three justices all are running individually but we have seen all are running in different order but if I have to give a specific sequence I can add priority here priority equal to one so less priority may get executed for so if I say priety one this will executed first and if I give pratik two this will get executed and if I keep right III this will get executed if you want to check just right click and run as test in G test and now you can see all are running based on our requirement right so now it's turning logging first then select rating and then check out let me go back to console window I cannot understand what exactly this desk is the State login application select item checkout so if you want to add some description to a test like what exactly this desk is this so you can add description as well you can see here if you add description this thing will appear in the HTML report and it will also appear on the standard output let me show you it's very important feature which I use in my screen book so in the description I will say this first case will verify login functionality same thing I will do here I will just write the description equal to this test case will add certain items in basket and the last one I will add one more description like this test case will perform checkout operation so now we have all the three - cases now every test gate has some description so when you run your test you can understand easily what exactly is this disc is this so let's wait for the complete execution so you can see after every test now you had least some description like this test case will verify the log in this test case will add certain items and so on so this is very important because whenever you send a report to the client or your team or your managers at least they can understand what is this test case is doing this all the features you will not get in if you start working with plain Java code so better to use some simple now the very important part if you simply right-click and click on refresh you will see a separate folder created this folder generated automatically by testing so you can see we have multiple folders here and from HTML files so let me show you the first one enable report dot HTML file as the name you can understand it's a report that you can send us an email so it's coming in Eclipse let me show you in right you can see there are so many tests are coming so as of now I can see the complete test Smith name is default test because by default it is a sine beta stingy total number of test cases pass three zero failed zero total time is fifty nine milliseconds it's coming in milliseconds because we are just writing system dot out dot print end but when you start writing your actual test you will get to know like each test is taking some time so I'm now going to stick into 30 seconds or checkout is taking 15 second and so on so these are the test and you can see if you click on checkout right now all are coming here only but if you have multiple test cases if you click on a specific test it will show you the complete information you can see two more options are coming groups so groups I love the group features because group will add more value to your test suite so you can create multiple group then you can run groups as well so group part will see later as of now this is our first report and if I go back you can see is a folder name is default suite and this default suit is coming just because in XML the default seat was mentioned right and this is another HTML report default test dot HTML opening in different editor let me open in browser so you can see every time you run your test it will create three different kind of report so this is type two so it's coming in a different format so let's say if you have file type C you will get file type of report in this format email enable report will be the combined one but if you want report or based on the specific test suite you will use this kind of report so you can see the same thing a number of paths we'll just get started on total time groups are empty as a small because we have not added any group and this is the description which you have added so now if you send this report they can easily check what exactly this test case is right so this is very important feature which I use so I will also recommend you to use it and the last but not the least this is your index data schema this is little bit technical see we we will be using this for over understanding not for the reporting purpose so if you open this in a browser so you can see this is the XML file which is internally generated and executed by test in G which I showed just now so default of test feed was before suite and test was the for test and best is your classes so one test class zero groups total time is this as of not reported output is null because we have not added any reported this is a chronicle view and the last one is this check out log in application and select item so if you don't want to add any additional kind of report you can use this report anyways I use extent report for my project because extend report gives you so much flexibility to add the screenshots as well with somehow we need to add so much line of code virtus ng built in extant report we have just one method and we can attach the port and logs as well so I guess I had covered all the points which I was able to cover today so check Justin he advantages installation create first script create multiple test checking auto-generated XML checking the fourth in adding details to attack they also added one more point here's how to run build on the priority now I have a very interesting and interview question as well what if I give priority as minus three will it work so per question will come in this wave discussed in the support negative priority if yes then what will be the output so yes destiny supports negative priorities as well safety give minus 3 so minus 3 is less than 1 so check out will execute for so if you run your test now if this minus 3 is lower so first check out will run and then it will start login and select item so you can see it started with check out feature self now or the final works the good thing about testing G is let's say if you have multiple test cases is one of the test is failing it will stop it will not stop the other test cases let me show you let's say this login has been failed so there is one a first class intestine G so assert comes with different packages we select this one and a third equal so a sirs we will use again when we have to compare actual versus expected so if I say actual is 12 but I am expecting 13 so definitely this will fail right so this test case will fail but testing G will continue with the best two test cases so if you are completely unaware of assert I have two videos on assert what is soft soft assert harder third how to use them but as of now forcefully I am failing this test so assert is a class in tests ng assertequals is a static method which will compare the actual versus expected so actual world 12 and expecting 13 so definitely this test case will fail but it will not stop the test yet it will continue with rest of the test cases so you can see test failed so one field is this and you will get this very meaningful message expected verse 13 but formal select item / checks check out path and if you refresh your project okay so now you can see again a new report has been generated so if I open with web browser you can see it's coming in dark red color so definitely uses so much flexibility even you can change the dis complete layout you can change into different colors so since this desk is face you can see expected for 13 but phones will but first to test cases over two things okay this is what I have for this video in future videos I will show you so many features of essenti that you will fall in love with this index will create group will create multiple tests week we will do the dependencies so in this scenario you can see ideally if my login is getting filled it should not execute the rest two test cases because these two test cases are dependent on the first one right so how we can create this kind of relationships in the test cases like if one test case is getting paid to node the rest of the test cases in other words you can consider if my webpage distance is not loading then it does not make any sense to run all the tests right so we create that kind of scenarios in the future videos so that's all I have for this video if you have any doubt you can contact me and thank you so much I will be publishing some more video on REST API use using a short thin features reduce you can expect more on EPA testing as well thank you so much if you hand it out just feel free to contact me if you like this video hit the like button below or you can comment and please pause on this channel with your friends thank you so much
Info
Channel: Mukesh otwani
Views: 223,797
Rating: 4.9341402 out of 5
Keywords: Selenium WebDriver Tutorial, Testng Tutorial for Beginners, Testng Tutorial, Test Automation, Automation Testing, JUnit
Id: OTtFSnZY4f8
Channel Id: undefined
Length: 31min 32sec (1892 seconds)
Published: Mon Jan 16 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.