I want to be as flexible as possible with my test suites - I want to be able to:
- run all tests by priority (p1, p2...) - this is easy
- run all tests by module (module1, module2...) - this is easy
- run tests that are a specific priority and specific module - I can't figure out
I have some tests thusly:
@Test(groups = {"p1", "module1"})
public void p1module1() {
System.out.println("p1module1");
}
@Test(groups = {"p2", "module1"})
public void p2module1() {
System.out.println("p2module1");
}
@Test(groups = {"p1", "module2"})
public void p1module2() {
System.out.println("p1module2");
}
@Test(groups = {"p2", "module2"})
public void p2module2() {
System.out.println("p2module2");
}
But if I do something like this
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="qa-selenium">
<test name="My Suite">
<groups>
<run>
<include name="p1"/>
<include name="module1"/>
</run>
</groups>
<packages>
<package name="com.mycompany.qa.selenium.*"/>
</packages>
</test>
</suite>
the includes are treated like an OR, but I want an AND. In this case I want to create a suite that ONLY executes p1module1()
I realize I could use tons of excludes - in this example
<exclude name="p2"/>
<exclude name="module2"/>
but I really want to avoid this. Is there a way to do this, preferably without metaprogramming?