Software Testing Material

A site for software testers. We provide free online tutorials on Manual Testing, Automation Testing - Selenium, QTP, LoadRunner, Testing Tools and many more.

  • Blog
  • Tutorials
    • Manual Testing
    • Java
    • Selenium
      • TestNG
      • Maven
      • Jenkins
    • Framework
    • Katalon
    • Agile
    • SQL
    • VBScript
    • API Testing
  • Tools
    • TestLodge
    • FrogLogic GUI Tool
    • CrossBrowserTesting
    • BrowserStack
    • TestCaseLab
    • Kobiton
    • PractiTest
    • Sikuli
    • Postman
  • Interview Q & A
    • Selenium
    • TestNG
    • Test Framework
    • Explain Framework
    • Manual Testing
    • Software QA
    • Agile
    • Testing As A Career
    • General Interview Questions
    • API Testing
    • SOAP
    • JIRA
    • Protractor
  • Free Resources
  • Guest Post
    • Guest Post Guidelines
  • Training

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

Last Updated on March 15, 2017 by Rajkumar

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.

TestNG.xml
1
2
3
4
5
6
7
<suite name="softwaretestingmaterial">
<test name="testngTest">
<classes>
<class name="softwareTestingMaterial.STMTestNGClass" />
</classes>
</test>
</suite>

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.

SUBSCRIBE TO GET FREE EBOOK AND REGULAR UPDATES ON SOFTWARE TESTING

Filed Under: Selenium, TestNG

data-matched-content-rows-num="2" data-matched-content-columns-num="3"
Previous Article:
How To Handle Drop Down And Multi Select List Using Selenium WebDriver
Next Article:
How to Download and Install Apache ANT | Software Testing Material

About the Author

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

ADVERTISEMENT

Froglogic-Squish-GUI-Tester
CrossBrowserTesting

TUTORIALS

  • Manual Testing Tutorial
  • Selenium Tutorial
  • TestNG Tutorial
  • VBScript Tutorial
  • Agile Methodology
  • SQL Tutorial for Testers
  • INTERVIEW QUESTIONS

  • Framework Interview Questions
  • Real Time Manual Testing
  • 100 Top Selenium Interview Questions
  • 30 Top TestNG Interview Questions
  • Agile Interview Questions
  • 80 SQL Interview Questions
  • TESTING TOOLS

  • Test Lodge
  • FrogLogic Squish
  • Cross Browser Testing
  • BrowserStack
  • Test Case Lab
  • Sikuli
  • © 2019 www.softwaretestingmaterial.com | About us | Privacy Policy | Contact us | Guest Post | Disclaimer | Terms of use | Sitemap