Search in sources :

Example 1 with XmlMethodSelector

use of org.testng.xml.XmlMethodSelector in project druid by druid-io.

the class TestNG method createSuiteRunners.

/**
   * Creates the {@code SuiteRunner}s and populates the suite runner map with
   * this information
   *
   * @param suiteRunnerMap Map with XMLSuite as key and it's respective
   *                       SuiteRunner as value. This is updated as part of this method call
   * @param xmlSuite       Xml Suite (and its children) for which {@code SuiteRunner}s are created
   */
private void createSuiteRunners(SuiteRunnerMap suiteRunnerMap, /* OUT */
XmlSuite xmlSuite) {
    if (null != m_isJUnit && !m_isJUnit.equals(XmlSuite.DEFAULT_JUNIT)) {
        xmlSuite.setJUnit(m_isJUnit);
    }
    // takes precedence
    if (null != m_skipFailedInvocationCounts) {
        xmlSuite.setSkipFailedInvocationCounts(m_skipFailedInvocationCounts);
    }
    // Override the XmlSuite verbose value with the one from TestNG
    if (m_verbose != null) {
        xmlSuite.setVerbose(m_verbose);
    }
    if (null != m_configFailurePolicy) {
        xmlSuite.setConfigFailurePolicy(m_configFailurePolicy);
    }
    for (XmlTest t : xmlSuite.getTests()) {
        for (Map.Entry<String, Integer> ms : m_methodDescriptors.entrySet()) {
            XmlMethodSelector xms = new XmlMethodSelector();
            xms.setName(ms.getKey());
            xms.setPriority(ms.getValue());
            t.getMethodSelectors().add(xms);
        }
    }
    suiteRunnerMap.put(xmlSuite, createSuiteRunner(xmlSuite));
    for (XmlSuite childSuite : xmlSuite.getChildSuites()) {
        createSuiteRunners(suiteRunnerMap, childSuite);
    }
}
Also used : XmlSuite(org.testng.xml.XmlSuite) XmlMethodSelector(org.testng.xml.XmlMethodSelector) XmlTest(org.testng.xml.XmlTest) Map(java.util.Map) SuiteRunnerMap(org.testng.internal.SuiteRunnerMap)

Example 2 with XmlMethodSelector

use of org.testng.xml.XmlMethodSelector in project druid by druid-io.

the class TestNG method initializeConfiguration.

private void initializeConfiguration() {
    ITestObjectFactory factory = m_objectFactory;
    //
    // Install the listeners found in ServiceLoader (or use the class
    // loader for tests, if specified).
    //
    addServiceLoaderListeners();
    //
    for (XmlSuite s : m_suites) {
        for (String listenerName : s.getListeners()) {
            Class<?> listenerClass = ClassHelper.forName(listenerName);
            // If specified listener does not exist, a TestNGException will be thrown
            if (listenerClass == null) {
                throw new TestNGException("Listener " + listenerName + " was not found in project's classpath");
            }
            Object listener = ClassHelper.newInstance(listenerClass);
            addListener(listener);
        }
        //
        for (XmlMethodSelector methodSelector : s.getMethodSelectors()) {
            addMethodSelector(methodSelector.getClassName(), methodSelector.getPriority());
        }
        //
        if (s.getObjectFactory() != null) {
            if (factory == null) {
                factory = s.getObjectFactory();
            } else {
                throw new TestNGException("Found more than one object-factory tag in your suites");
            }
        }
    }
    m_configuration.setAnnotationFinder(new JDK15AnnotationFinder(getAnnotationTransformer()));
    m_configuration.setHookable(m_hookable);
    m_configuration.setConfigurable(m_configurable);
    m_configuration.setObjectFactory(factory);
}
Also used : XmlSuite(org.testng.xml.XmlSuite) XmlMethodSelector(org.testng.xml.XmlMethodSelector) JDK15AnnotationFinder(org.testng.internal.annotations.JDK15AnnotationFinder)

Aggregations

XmlMethodSelector (org.testng.xml.XmlMethodSelector)2 XmlSuite (org.testng.xml.XmlSuite)2 Map (java.util.Map)1 SuiteRunnerMap (org.testng.internal.SuiteRunnerMap)1 JDK15AnnotationFinder (org.testng.internal.annotations.JDK15AnnotationFinder)1 XmlTest (org.testng.xml.XmlTest)1