Execute selective test case to meet test requirements
While testing it is necessary to execute “Sanityonly” test cases. e.g. As soon as build is ready, run only “sanity test cases” to validate stability of build.
TestNG allows to group tests per above execution requirements.
Steps to follow:
Step 1: Create tests with “group” tag e.g.
@Test(groups = {“smoketest”, “functionaltest”, “regression”})
public void testcaseOne(){
System.out.println(“hello unit group”);
}
@Test(groups = {“functionaltest”})
public void testcaseTwo(){
System.out.println(“hello unit group”);
}
Step 2: Update “testng.xml” with groups to run. e.g.
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”>
<suite name=”Suite”>
<test name=”GroupTest”>
<groups>
<run>
<include name=”smoketest” />
</run>
</groups>
<classes>
<class name=”com.project.xx.classnamewithout.javaextension” />
….all other classnames
….
</classes>
</test> <!– GroupTest –>
</suite> <!– Suite –>
Step 3: Execute “testng.xml”
This will run only testcaseOne() test case.
0 comments