Another option is to use a suite-of-suites. I'll preface this by saying it's been a while since I've worked with this setup, but hopefully you'll find enough detail here to at least get started.
First, you'd define two (or more) suite XML files:
<suite name="Suite1">
<test name="test1">
<classes>
<class name="fully.qualified.ClassName" />
</classes>
<methods>
<include name="method1" />
</methods>
</test>
</suite>
and...
<suite name="Suite2">
<test name="test2">
<classes>
<class name="fully.qualified.ClassName" />
</classes>
<methods>
<include name="method2" />
</methods>
</test>
</suite>
Then, you'd define a suite-of-suites XML file:
<suite name="suite of suites">
<suite-files>
<suite-file path="Suite1.xml" />
<suite-file path="Suite2.xml" />
</suite-files>
</suite>
Do note, that the suite-file
path value is the relative path from the current suite-of-suites XML file to the XML file you're calling. If they're in the same directory, simply the file name will suffice.
Additionally, both XML types do support the <parameter>
tag. The standard suite XML will read both at <suite>
and in the <test>
levels, and I've found that <parameter>
tags at the <suite>
level on the suite-of-suites XML file will work as well.
Finally, on execution, you'd need only pass in the suite-of-suites XML file as your suite file argument.
EDIT:
Here's how I was able to make my two suites run in parallel. The trick was setting up my main()
method properly.
public class TestRunner
{
public static void main(String[] args)
{
TestNG testng = new TestNG();
TestListenerAdapter adapter = new TestListenerAdapter();
List<String> suites = new ArrayList<String>();
testng.addListener(adapter);
suites.add(args[0]);
testng.setTestSuites(suites);
testng.setParallel("parallel");
testng.setSuiteThreadPoolSize(5);
testng.setOutputDirectory("path to output");
testng.run();
}
}
Then, on the command line:
java -jar ParallelSuiteDemo.jar SuiteOfSuites.xml
Note, my jar and all xml files were in the same directory with this configuration. The command line args and <suite-file>
entries would need to be configured properly if you wish you use a directory structure.
This yielded my two suite.xml files running in parallel on a Selenium Grid.
There may be better ways of doing this, to be honest. This is just what worked for me when I was trying to do something similar.