class TestNG {
/**
* @return a list of XmlSuite objects that represent the list of classes and methods passed
* in parameter.
*
* @param commandLineMethods a string with the form "com.example.Foo.f1,com.example.Bar.f2"
*/
private List<XmlSuite> createCommandLineSuitesForMethods(List<String> commandLineMethods) {
//
// Create the <classes> tag
//
Set<Class> classes = Sets.newHashSet();
for (String m : commandLineMethods) {
Class c = ClassHelper.forName(splitMethod(m)[0]);
if (c != null) {
classes.add(c);
}
}
List<XmlSuite> result = createCommandLineSuitesForClasses(classes.toArray(new Class[0]));
//
// Add the method tags
//
List<XmlClass> xmlClasses = Lists.newArrayList();
for (XmlSuite s : result) {
for (XmlTest t : s.getTests()) {
xmlClasses.addAll(t.getClasses());
}
}
for (XmlClass xc : xmlClasses) {
for (String m : commandLineMethods) {
String[] split = splitMethod(m);
String className = split[0];
if (xc.getName().equals(className)) {
XmlInclude includedMethod = new XmlInclude(split[1]);
xc.getIncludedMethods().add(includedMethod);
}
}
}
return result;
}
}