TestNG Tutorials 40: Groups of Groups or MetaGroups in TestNG

Hello Folks,

Grouping is a best feature provided by TestNG. We group test scripts based on suite name or functionality based on our requirements. We have seen grouping concepts in previous posts. In this post we will another feature of grouping in TestNG.

TestNG also allows you to create group of groups i.e. meta data.

For example: Suppose a module has many submodules. For better categorisation you tag test methods based on submodules names. Now if you want to run all test methods for that module,  you need to use several include tags under groups tag. Something like below:

It will be difficult to maintain if there are more numbers of modules and sub modules. TestNG allows you to define groups of groups i.e. a group which contains another group in it. You need to use “define” tag and provide name to metagroup.

You can see how I created two groups and each groups contain multiple sub modules. To run a meta group, just you need to call that metagroup name under run tag as we use for normal group.

On run, it will include all methods from sub modules included in “Module 1” meta group.

TestNG Class:

Testng xml:


More about TestNG in upcoming posts. Stay tuned.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.

Table of Contents

Author: Amod Mahajan

A software Tester who is paid to judge products developed by others. Writing technical posts and creating YouTube videos are my hobbies.

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.