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

Adding Packages to testng.xml file





Adding Packages to testng.xml file, will explain you about creating and configuring TestNG test suite with packages which are developed/created in the java project. A Package may contain one or more classes in it. With this testng.xml configuration file we can include all the classes belongs to  a particular package or its subpackages to the test suite.

Below are The Steps for Adding Packages to testng.xml file:

1.Create a java project with multiple packages and multiple classes in each package.

1. Project with Multiple Packages

2.In the above project; created 3 packages called (com.test.firstpackage, com.test.secondpackage and           com.test.thirdpackage) and each package had 2 classes.

3.Now create a testng.xml file (here the xml file name is “testng-packages.xml”) with below code/configuration content.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
  <test name="PackageTest">
    <packages>
      <package name="com.test.firstpackage"/>
      <package name="com.test.secondpackage"/>
      <package name="com.test.thirdpackage"/>
    </packages>
  </test> <!-- Test -->
</suite> <!-- Suite -- >

In the above code, packages will be reside in the “packages” tag and the each individual package will be in the “package” tag with “name” attribute.

4.Now execute the “testng-packages.xml” file from eclipse as TestNG suite.

Then you can see the  following output.

2. Multiple Package Test Result

This way we can configure the packages in the testng xml configuration file to execute the scripts as packages and can analyse the test results.



Share this post: on Twitter on Facebook

Creating testng.xml file with multiple tests Adding Classes 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