Package execution using TestNG xml

Let us consider a scenario where you want to execute all the test case of all the classes in a package. This can easily be done via TestNG.xml file. In TestNG.xml we can include a package or packages.

Below is the sample of TestNG.xml file to run all the test cases of a package.

Here, in above testng.xml file a package with name com.qatechhub.testng.package1 is included. Let us consider this package consist of two different classes with name TestClass1 and TestClass2.

After executing testng.xml file all the test cases of these above-mentioned classes will be executed.

Code of TestClass1:

Code of TestClass2:

Result of above execution:


HTML Report of above code:


In this way we can execute test cases of all the classes in a package or multiple packages.

PS: For any questions queries or comment feel free to write us at or Happy Learning 🙂

Saurabh Dhingra

About the Author

Saurabh Dhingra

Follow Saurabh Dhingra: