TestNg Groups

Grouping is very good feature of testng. Its a next generation testing techniques. In previous blog we learn what is TestNg, how to execute Testng program etc. Now we explain how to make groups in testng.

Benefits of grouping: Suppose we have 100 test methods in a single test class and we defined some high priority test methods and some low priority test methods.From these method we want to run only high priority test methods. So we can easily make the groups for it.

We will create test case and we will defined some methods where we can defined high, low priority.

Here is the code:

For grouping we have to define groups in testing.xml.Here we run the only high priority test methods.

In testing xml we defined <groups> and <run> tag. <groups> tag defines the group and </run> tag represents the group that needs to be run.

 

testng result

We can easily see the html report which is generated by testng.

testng report

login and search data are the high priority groups so when define high priority groups in testng.xml it run the only high priority groups test methods.

Written by 

Principal Architect at Knoldus Inc

Leave a Reply

%d bloggers like this: