Package execution using TestNG xml

a couple of years ago

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:

Leave a Comment: