group test cases in TestNG

Modified on Tue, 28 Mar, 2023 at 4:31 PM

To group test cases in TestNG, you can use the “groups” attribute in the @Test annotation. Assign a group name to each test case, and then create a testng.xml file to include or exclude specific groups from the test run. You can also use the “include” or “exclude” tags to specify which test groups to include or exclude from the test run.


Groups can be created on the testng.xml file as shown below 


The created groups then can be added to the tests.


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article