SELENIUM BASICS:


SELENIUM WEBDRIVER:


TESTNG:


REPORTS:


BUILD & CONTINUOUS INTEGRATION TOOLS:


CROSS BROWSER TESTING:


MOBILE TESTING:


AUTOMATION FRAMEWORKS:


API Testing:


INTERVIEW QUESTIONS:


SAMPLE RESUME:

How To Create TestNG XML File And Execute TestNG.XML File

Create TestNG XML file:

In TestNG framework, we need to create Testng xml file to create and handle multiple test classes. We do configure our test run, set test dependency, include or exclude any test, method, class or package and set priority etc in the xml file.

Please be patient. The video will load in some time.

Steps to create TestNG XML file 

Step 1: Create testng xml file

i. Right click on Project folder, go to New and select ‘File‘ as shown in below image.

Create TestNG XML

ii. In New file wizard, add file name as ‘testng xml‘ as shown in below given image and click on Finish button.

Create TestNG XML

iii. It will add testng xml file under your project folder.

Step 2 : Write xml code: 

i. Now add below given code in your testng xml file.

Note: You can choose any name for your Test Suite & Test Name as per your need.

ii. After giving appropriate names, now your testng xml file will looks like this:

Create TestNG XML

The hierarchy in the testng xml file is very simple to understand.

Very first tag is the Suite tag<suite>, under that it is the Test tag<test> and then the Class tag<classes>. You can give any name to the suite and the test but you need to provide the correct name to the <classes> tag which is a combination of your Package name and Test Case name.

eg. Package Name is “softwareTestingMaterial”, Test Case Name is “STMTestNGClass”. So the Class Name should be softwareTestingMaterial.STMTestNGClass

Step 3 : Execute a testng xml

Now let’s run the xml. Run the test by right click on the testng xml file and select Run As > TestNG Suite.

Create TestNG XML

Once the execution is done, you could view test result under the TestNg console.

Create TestNG XML Create TestNG XML

You could find the complete TestNG tutorial here.

TestNG Complete Tutorial

If you are not regular reader of my blog then I highly recommend you to signup for the free email newsletter using the below link.

Sharing is caring.

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

Like This Post?

We have a lot more where that came from?

We only send really good stuff occasionally, promise.

Rajkumar

Leave a Comment

API Testing eBook

DOWNLOAD FOR FREE