Description and Grouping Concept in TestNG

Posted By : Manish Kumar | 26-Feb-2018

As the number of modules in a project is increasing so as the number of methods in automation framework, with the same difficulty level of maintaining methods which need to be executed at a time and which are not.

 
To simplify this difficult task, one can use TestNG Description and Grouping concept, where we can give/assign the group names for methods and define executables at any moment.
 
 
 To understand better. give a look to below code:

 

package testng; import org.testng:grouping.one; public class TestNG_group { @Test(description="This is new account method", groups={"function", "smoke"}) public void NewAccount() { System.out.println("This is new account method "); } @Test(description="This is new user method ", groups={"function"}) public void NewUser() { System.out.println("This is new user method "); } @Test(description="This is new freelancer method ", groups={"smoke"}) public void test3() { System.out.println("This is new freelancer method "); } }

This is what we need to do and then when we need to execute:

 

The test.xml file will have below < exclude name=“function”/>

 
 
And, output  will contain only method 3 as we have excluded function.
 
 
 
 
 
 
Related Tags

About Author

Author Image
Manish Kumar

Manish is Adaptive and passionate to learn new technical skills, have knowledge of testing and love to play badminton in free time

Request for Proposal

Name is required

Comment is required

Sending message..