Search in sources :

Example 1 with XmlSuite

use of org.testng.xml.XmlSuite 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 XmlSuite

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

the class TestNG method runSuitesSequentially.

/**
   * Recursively runs suites. Runs the children suites before running the parent
   * suite. This is done so that the results for parent suite can reflect the
   * combined results of the children suites.
   *
   * @param xmlSuite         XML Suite to be executed
   * @param suiteRunnerMap   Maps {@code XmlSuite}s to respective {@code ISuite}
   * @param verbose          verbose level
   * @param defaultSuiteName default suite name
   */
private void runSuitesSequentially(XmlSuite xmlSuite, SuiteRunnerMap suiteRunnerMap, int verbose, String defaultSuiteName) {
    for (XmlSuite childSuite : xmlSuite.getChildSuites()) {
        runSuitesSequentially(childSuite, suiteRunnerMap, verbose, defaultSuiteName);
    }
    SuiteRunnerWorker srw = new SuiteRunnerWorker(suiteRunnerMap.get(xmlSuite), suiteRunnerMap, verbose, defaultSuiteName);
    srw.run();
}
Also used : XmlSuite(org.testng.xml.XmlSuite)

Example 3 with XmlSuite

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

the class TestNG method populateSuiteGraph.

/**
   * Populates the dynamic graph with the reverse hierarchy of suites. Edges are
   * added pointing from child suite runners to parent suite runners, hence making
   * parent suite runners dependent on all the child suite runners
   *
   * @param suiteGraph     dynamic graph representing the reverse hierarchy of SuiteRunners
   * @param suiteRunnerMap Map with XMLSuite as key and its respective SuiteRunner as value
   * @param xmlSuite       XML Suite
   */
private void populateSuiteGraph(DynamicGraph<ISuite> suiteGraph, /* OUT */
SuiteRunnerMap suiteRunnerMap, XmlSuite xmlSuite) {
    ISuite parentSuiteRunner = suiteRunnerMap.get(xmlSuite);
    if (xmlSuite.getChildSuites().isEmpty()) {
        suiteGraph.addNode(parentSuiteRunner);
    } else {
        for (XmlSuite childSuite : xmlSuite.getChildSuites()) {
            suiteGraph.addEdge(parentSuiteRunner, suiteRunnerMap.get(childSuite));
            populateSuiteGraph(suiteGraph, suiteRunnerMap, childSuite);
        }
    }
}
Also used : XmlSuite(org.testng.xml.XmlSuite)

Example 4 with XmlSuite

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

the class TestNG method checkSuiteNamesInternal.

private void checkSuiteNamesInternal(List<XmlSuite> suites, Set<String> names) {
    for (XmlSuite suite : suites) {
        final String name = suite.getName();
        if (names.contains(name)) {
            throw new TestNGException("Two suites cannot have the same name: " + name);
        }
        names.add(name);
        checkSuiteNamesInternal(suite.getChildSuites(), names);
    }
}
Also used : XmlSuite(org.testng.xml.XmlSuite)

Example 5 with XmlSuite

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

the class TestNG method checkTestNames.

/**
   * Ensure that two XmlTest within the same XmlSuite don't have the same name
   */
private void checkTestNames(List<XmlSuite> suites) {
    for (XmlSuite suite : suites) {
        Set<String> testNames = Sets.newHashSet();
        for (XmlTest test : suite.getTests()) {
            if (testNames.contains(test.getName())) {
                throw new TestNGException("Two tests in the same suite " + "cannot have the same name: " + test.getName());
            } else {
                testNames.add(test.getName());
            }
        }
        checkTestNames(suite.getChildSuites());
    }
}
Also used : XmlSuite(org.testng.xml.XmlSuite) XmlTest(org.testng.xml.XmlTest)

Aggregations

XmlSuite (org.testng.xml.XmlSuite)22 XmlTest (org.testng.xml.XmlTest)12 XmlClass (org.testng.xml.XmlClass)8 XmlInclude (org.testng.xml.XmlInclude)5 ArrayList (java.util.ArrayList)3 File (java.io.File)2 Test (org.junit.Test)2 SuiteRunnerMap (org.testng.internal.SuiteRunnerMap)2 Parser (org.testng.xml.Parser)2 XmlMethodSelector (org.testng.xml.XmlMethodSelector)2 ParameterException (com.beust.jcommander.ParameterException)1 CantRunException (com.intellij.execution.CantRunException)1 ExecutionException (com.intellij.execution.ExecutionException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 List (java.util.List)1 Map (java.util.Map)1 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1