When I attempt to group my tests in the Testng XML suite, all of the test methods are excluded in the test run.
I have written my tests in a way that I want all of the test methods in my class to be run, but only certain classes in the suite to be executed, so I have used class level annotations:
@Test (groups={ TestConstrants.Group1})
public class ABCTests extends AbstractIntegrationTest
{
@Test
public void Test1() throws Exception
@Test
public void Test2() throws Exception
}
@Test (groups={ TestConstrants.Group2})
public class DEFTests extends AbstractIntegrationTest
{
@Test
public void Test3() throws Exception
@Test
public void Test4() throws Exception
}
My Testng XML is configured for the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="SuiteGroup">
<test name="TestGroups" preserve-order="true">
<groups>
<run>
<include name="TestConstants.Group1"/>
<exclude name="TestConstants.Group2"/>
</run>
</groups>
<classes>
<class name="ABCTests"/>
<class name="DEFTests"/>
</classes>
</test> <!-- TestGroups -->
</suite> <!-- SuiteGroup -->
In this example, I would expect only the tests in class ABCTests to be ran, however, it appears all of the tests are being excluded for some reason. I have verified that the methods in the class I am extending (AbstractIntegrationTest) are set to 'alwaysRun = true'.
I know that I could simply not include the classes that I do not want to run, but I will potentially have hundreds of tests and it is much easier to maintain the test suite by group than class.