Selenium Webdriver Appium Complete TutorialSelenium Webdriver Appium Complete Tutorial
Automation Testing
  • Tools
    • Selenium
      • Selenium Java Tutorial
      • Selenium C# Tutorial
    • Appium
      • Appium Java Tutorial
      • Appium C#Tutorial
    • Katalon
  • Trainings
  • TestNG
  • Reports
    • Extent Reports
      • Extent Reports – Java
      • Extent Reports – Java -Version3
      • Extent Reports – C#
    • Vigo Reports
    • AT Excel Report
  • Excel
    • Apache POI – Java
    • Excel With C#
  • Interview Questions
    • Selenium Interview Questions
    • Java Interview Questions
    • C# Interview Questions
  • Demo Site
  • Practice Site
  • More…
    • AutoIt
    • Sikuli
    • Robot Class
    • File Upload
    • ScreenShot
      • AShot
      • ShutterBug
  • About
December 13, 2016

Creating testng.xml file with multiple tests





In our previous blog, we have created a testng.xml file with only one test in a suite. But, TestNG allows to define multiple tests in a single suite. This way we can segregate our tests and can create different tests based on our requirement (i.e. smoke tests, sanity tests and integration tests etc…).

Now we’ll see  creating multiple tests in testng.xml file:

1.Open eclipse and create a project with multiple test classes (i.e. multiple Java files)
2.Create a testng.xml file.
Can see the screenshot below for the same.

1. Sample Project with multiple classes

3.Now will update the testng.xml file with multiple tests in a single suite.

Below is the screenshot for the same:

2. testng.xml with multiple tests

The testng.xml file defines a suite with the name Suite. The suite contains two tests with names FirstTest and SecondTest respectively. These tests are configured to execute separate classes “com.test.testngframework.FirstTest” and “com.test.testngframework.SecondTest”.

When the testng.xml file is executed as a suite in TestNG, each class is executed by a separate test section of a suite.

4.Now run the testng.xml file and see the generated output.

Below is the screenshot for the same:

3. multiple tests output

This way we can include multiples tests according to our requirement and execute the same. Once the output is generated, we can able to see the results as separate tests to understand and analyse the report.



Share this post: on Twitter on Facebook

Running testng.xml using Eclipse Adding Packages to testng.xml file

Related Posts

Excel to DataProvider

TestNG

Read data from Excel to DataProvider in Selenium

Running TestNG programmatically

TestNG

Running TestNG Tests Programmatically

EXECUTING ONLY FAILED TESTS

TestNG

Executing Only Failed Tests in TestNG

Capture Screenshot for Failed Tests

TestNG

Capture Screenshot for Failed Tests in TestNG

Preserve Order in TestNG

TestNG

Preserve Order in TestNG

PRIORITIZING TESTS

TestNG

Prioritizing Tests in TestNg

EXECUTE MULTIPLE XML FILES

TestNG

Execute Multiple XML files in TestNG

CUSTOM REPORTER IN TESTNG (1)

TestNG

Custom Reporter in TestNG

CUSTOM LOGGER IN TESTNG

TestNG

Custom Logger in TestNG

ASSERTIONS

TestNG

TestNG Assertions

Newsletter

Recent Posts

  • TAKING WEB ELEMENT SCREENSHOT IN SELENIUMHow to Capture WebElement Screenshot in Selenium Webdriver using selenium 4
    December 15, 2019
  • How To SWAP Two Numbers in Java Without using Temp VariableHow to SWAP Two Numbers in Java Without Temp variable or Without Third variable
    December 8, 2019
  • How to Swap Two Numbers in Java with Temp VariableHow to SWAP Two Numbers in Java using Temp Variable
    December 1, 2019
  • How to Read Properties file in JavaHow to Read Data From Properties File in Java
    November 27, 2019
  • Compare two arrays in java with out inbuilt functionsHow to Compare Two Arrays in Java without built-in functions
    November 16, 2019
© Selenium Webdriver Appium Complete Tutorial 2025