Search code examples
javaannotationstestngtestng-dataprovider

TestNg Annotation Syntax


I started learning TestNG but i got stuck so i need little help related to syntax I have already using annotation dataProvider

@Test(dataProvider="getdata")
public void testCase02(String text1,String text2){
    System.out.println("I m in second testcase");
    System.out.println(text1);`
    System.out.println(text2);
}

But i also want to use annotation (groups="group") so can anyone help me out for syntax to use both annotation together.


Solution

  • To mark a test method to belong to a group, you need to do is specify the groups attribute of the Test

    @Test(dataProvider="getdata", groups = {"groupName"})
    public void testCase02(String text1,String text2) {
    

    There is a detailed documentation from testng around it.