Include and Exclude Methods in TestNG

package testng;

import org.testng.annotations.Test;

public class IncludeandExclude 
{
	@Test
	public void TestCase1()
	{
		System.out.println("This is my 1st test case."+"\n");
	}
	
	@Test
	public void TestCase2()
	{
		System.out.println("This is my 2nd test case."+"\n");
	}
	
	@Test
	public void TestCase3()
	{
		System.out.println("This is my 3rd test case."+"\n");
	}

}

testng.xml

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Include and Exclude Test Suite" verbose="1" >
  <test name="Method Test Cases" >
    <classes>
       <class name="testng.IncludeandExclude">
        <methods>
        <include name="TestCase1" />
        <include name="TestCase2" />
        <exclude name="TestCase3" /> 
      </methods>
       </class>
    </classes>
  </test>
</suite>

Output

[TestNG] Running:
  E:\Selenium\Myscripts\testng.xml

This is my 1st test case.

This is my 2nd test case.


===============================================
Include and Exclude Test Suite
Total tests run: 2, Failures: 0, Skips: 0
===============================================

 

Leave a Reply

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