use of org.testng.xml.XmlInclude in project druid by druid-io.
the class TestNG method createCommandLineSuitesForMethods.
/**
* @param commandLineMethods a string with the form "com.example.Foo.f1,com.example.Bar.f2"
*
* @return a list of XmlSuite objects that represent the list of classes and methods passed
* in parameter.
*/
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;
}
use of org.testng.xml.XmlInclude in project intellij-community by JetBrains.
the class TestNGTreeHierarchyTest method doTest.
private static void doTest(XmlSuite suite, String expected) {
final StringBuffer buf = new StringBuffer();
final IDEATestNGRemoteListener listener = createListener(buf);
for (XmlTest test : suite.getTests()) {
for (XmlClass aClass : test.getClasses()) {
final String classFQName = aClass.getName();
for (XmlInclude include : aClass.getIncludedMethods()) {
final String methodName = include.getName();
List<Integer> numbers = include.getInvocationNumbers();
if (numbers.isEmpty()) {
numbers = Collections.singletonList(0);
}
for (Integer integer : numbers) {
final MockTestNGResult result = new MockTestNGResult(classFQName, methodName, null, new Object[] { integer });
listener.onTestStart(result);
listener.onTestFinished(result);
}
}
}
}
Assert.assertEquals("output: " + buf, expected, StringUtil.convertLineSeparators(buf.toString()));
}
Aggregations