Search in sources :

Example 6 with XmlInclude

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;
}
Also used : XmlInclude(org.testng.xml.XmlInclude) XmlSuite(org.testng.xml.XmlSuite) XmlTest(org.testng.xml.XmlTest) XmlClass(org.testng.xml.XmlClass) XmlClass(org.testng.xml.XmlClass)

Example 7 with XmlInclude

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()));
}
Also used : XmlInclude(org.testng.xml.XmlInclude) XmlTest(org.testng.xml.XmlTest) IDEATestNGRemoteListener(org.testng.IDEATestNGRemoteListener) XmlClass(org.testng.xml.XmlClass)

Aggregations

XmlInclude (org.testng.xml.XmlInclude)7 XmlClass (org.testng.xml.XmlClass)6 XmlTest (org.testng.xml.XmlTest)6 XmlSuite (org.testng.xml.XmlSuite)5 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 File (java.io.File)1 List (java.util.List)1 IDEATestNGRemoteListener (org.testng.IDEATestNGRemoteListener)1