- Grouping of Test Cases
- Executing Particular Test Case more than once
- Dependency based Tests
public class TestNGExample
{
@Test(threadPoolSize = 4, invocationCount = 5, timeOut = 10000, groups = { "functional","BVT" })
//This method will be run a total of 5 times using 4 threads
public void TestCaseOne()
{
try
{
System.out.println("In Test Case One - Functional + BVT");
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
@Test(dependsOnMethods = "TestCaseOne" , groups = { "functional","BVT" }, invocationCount = 2, timeOut = 10000)
//This method will be run a twice
//Depends on TestCaseOne
public void TestCaseOneContinued()
{
try
{
System.out.println("In Test Case One Continued Functional + BVT");
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
@Test(groups = { "functional" })
//Grouped as Functional Test Case
public void TestCaseTwo()
{
try
{
System.out.println("In Test Case Two - Functional Testcase");
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
@Test(groups = { "BVT" })
//Part of BVT - Build Verification Cases
public void TestCaseThree()
{
try
{
System.out.println("In Test Case Three - BVT Test Case");
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
TestNG XML config is provided below
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="TestNGSuite" parallel="none" verbose="1">
<test name="BVTTestCaseExecution">
<groups>
<run>
<include name="BVT"/>
</run>
</groups>
<classes>
<class name="TestNGExample"/>
</classes>
</test>
<test name="Functional Test Cases Execution">
<groups>
<run>
<include name="functional"/>
</run>
</groups>
<classes>
<class name="TestNGExample"/>
</classes>
</test>
</suite>
Below is the output for the program. Right click on XML and run it as TestNG testGood Read
How does TestNG invoke a test method using multiple threads?
Happy Reading!!
No comments:
Post a Comment