Search in sources :

Example 1 with IAnnotationFinder

use of org.testng.internal.annotations.IAnnotationFinder in project druid by druid-io.

the class TestNG method createCommandLineSuitesForClasses.

private List<XmlSuite> createCommandLineSuitesForClasses(Class[] classes) {
    //
    // See if any of the classes has an xmlSuite or xmlTest attribute.
    // If it does, create the appropriate XmlSuite, otherwise, create
    // the default one
    //
    XmlClass[] xmlClasses = Utils.classesToXmlClasses(classes);
    Map<String, XmlSuite> suites = Maps.newHashMap();
    IAnnotationFinder finder = m_configuration.getAnnotationFinder();
    for (int i = 0; i < classes.length; i++) {
        Class c = classes[i];
        ITestAnnotation test = finder.findAnnotation(c, ITestAnnotation.class);
        String suiteName = getDefaultSuiteName();
        String testName = getDefaultTestName();
        boolean isJUnit = false;
        if (test != null) {
            suiteName = defaultIfStringEmpty(test.getSuiteName(), suiteName);
            testName = defaultIfStringEmpty(test.getTestName(), testName);
        } else {
            if (m_isMixed && JUnitTestFinder.isJUnitTest(c)) {
                isJUnit = true;
                testName = c.getName();
            }
        }
        XmlSuite xmlSuite = suites.get(suiteName);
        if (xmlSuite == null) {
            xmlSuite = new XmlSuite();
            xmlSuite.setName(suiteName);
            suites.put(suiteName, xmlSuite);
        }
        if (m_dataProviderThreadCount != null) {
            xmlSuite.setDataProviderThreadCount(m_dataProviderThreadCount);
        }
        XmlTest xmlTest = null;
        for (XmlTest xt : xmlSuite.getTests()) {
            if (xt.getName().equals(testName)) {
                xmlTest = xt;
                break;
            }
        }
        if (xmlTest == null) {
            xmlTest = new XmlTest(xmlSuite);
            xmlTest.setName(testName);
            xmlTest.setJUnit(isJUnit);
        }
        xmlTest.getXmlClasses().add(xmlClasses[i]);
    }
    return new ArrayList<XmlSuite>(suites.values());
}
Also used : XmlSuite(org.testng.xml.XmlSuite) ITestAnnotation(org.testng.annotations.ITestAnnotation) IAnnotationFinder(org.testng.internal.annotations.IAnnotationFinder) XmlTest(org.testng.xml.XmlTest) ArrayList(java.util.ArrayList) XmlClass(org.testng.xml.XmlClass) XmlClass(org.testng.xml.XmlClass)

Example 2 with IAnnotationFinder

use of org.testng.internal.annotations.IAnnotationFinder in project druid by druid-io.

the class DruidTestRunnerFactory method newTestRunner.

@Override
public TestRunner newTestRunner(ISuite suite, XmlTest test, List<IInvokedMethodListener> listeners) {
    IConfiguration configuration = TestNG.getDefault().getConfiguration();
    String outputDirectory = suite.getOutputDirectory();
    IAnnotationFinder annotationFinder = configuration.getAnnotationFinder();
    Boolean skipFailedInvocationCounts = suite.getXmlSuite().skipFailedInvocationCounts();
    return new DruidTestRunner(configuration, suite, test, outputDirectory, annotationFinder, skipFailedInvocationCounts, listeners);
}
Also used : IAnnotationFinder(org.testng.internal.annotations.IAnnotationFinder) IConfiguration(org.testng.internal.IConfiguration)

Aggregations

IAnnotationFinder (org.testng.internal.annotations.IAnnotationFinder)2 ArrayList (java.util.ArrayList)1 ITestAnnotation (org.testng.annotations.ITestAnnotation)1 IConfiguration (org.testng.internal.IConfiguration)1 XmlClass (org.testng.xml.XmlClass)1 XmlSuite (org.testng.xml.XmlSuite)1 XmlTest (org.testng.xml.XmlTest)1