I am trying to run all the test methods irrespective of whether they belong to any group or not.
Below is the Selenium code:
public class BaseClass
{
@BeforeMethod(onlyForGroups = {"P1"})
public void bmeth1()
{
System.out.println("Before Method1 called");
}
@BeforeMethod()
public void bmeth()
{
System.out.println("Before Method called");
}
@AfterMethod(onlyForGroups = {"P1"})
public void ameth1()
{
System.out.println("After Method1 called");
}
@AfterMethod()
public void ameth()
{
System.out.println("After Method called");
}
}
public class TC_003 extends BaseClass
{
@Test(groups= {"P1"})
public void tCase6()
{
System.out.println("Inside testcase 6");
}
@Test()
public void tCase9()
{
System.out.println("Inside testcase 9");
}
}
Below is the testng.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test name="Test1">
<classes>
<class name="testing.TC_003"/>
</classes>
</test>
</suite>
Actual Output:
Before Method called
Before Method1 called
Inside testcase 6
After Method called
After Method1 called
Before Method called
Inside testcase 9
After Method called
Expected Output:
Before Method1 called
Inside testcase 6
After Method1 called
Before Method called
Inside testcase 9
After Method called