TestNG @Test attributes – method description and grouping

description and droups

In framework and with growing number of automated test cases, it’s hard to maintain what test cases need to be executed for functional, regression or sanity etc, 
To avoid this, TestNG came up with nice concept called grouping (aka groups), where we can provide the group names in each @Test method and can run the respective grouping testNG.xml to run only required test cases.
To understand this, refer to the below code output

we can assign one or more group names to each of the @Test methods, as shown above

and the testng.xml looks like

<suite name=“Suite” parallel=“none”> 
<test name=“Test”> 
          <include name=“sanity”/>
          < exclude name=“funct”/>


This is method: test3
Only 3rd method executed, as we included “sanity” but excluded “funct”, 1st method din’t execute

Let’s change a bit in the groups tag of testng.xml,

This is method: test1
This is method: test3
Both 1st and 3rd method executed.

Content posted is based on learning or working experience,
Share the post with others if find useful,
Any queries?, leave comments or discuss on our facebook:qavalidation.com, Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *