Use Grouping in TestNG – Selenium Webdriver

package testng;

import org.testng.annotations.Test;

public class Grouping 
{
	@Test (groups={"regression"})
	public void testcase1()
	{
		System.out.println("It's Test case 1 and in regression group" +"\n");
	}
	@Test (groups={"unit"})
	public void testcase2()
	{
		System.out.println("It's Test case 2 and in unit group" +"\n");
	}
	@Test (groups={"regression"})
	public void testcase3()
	{
		System.out.println("It's Test case 3 and in regression group" +"\n");
	}

}

testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Grouping Test Case Suite">
  <test name="grouping">
  	<groups>
  	<define name = "all">
  		<include name="regression"/>
  		<exclude name="unit"/>
  	</define>
      <run>
        <include name="all"/>
      </run>
    </groups>
    <classes>
       <class name="testng.Grouping" />
    </classes>
  </test>
</suite>

 

Leave a Reply

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