Search in sources :

Example 1 with XmlTest

use of org.testng.xml.XmlTest in project powermock by powermock.

the class SimpleBaseTest method createXmlTest.

protected XmlTest createXmlTest(XmlSuite suite, String name, String... classes) {
    XmlTest result = new XmlTest(suite);
    int index = 0;
    result.setName(name);
    for (String c : classes) {
        XmlClass xc = new XmlClass(c, index++, true);
        result.getXmlClasses().add(xc);
    }
    return result;
}
Also used : XmlTest(org.testng.xml.XmlTest) XmlClass(org.testng.xml.XmlClass)

Example 2 with XmlTest

use of org.testng.xml.XmlTest in project powermock by powermock.

the class SimpleBaseTest method createXmlTest.

protected XmlTest createXmlTest(XmlSuite suite, String name, Class clazz, Class... classes) {
    XmlTest result = new XmlTest(suite);
    int index = 0;
    result.setName(name);
    XmlClass xc = new XmlClass(clazz.getName(), index++, true);
    result.getXmlClasses().add(xc);
    for (Class c : classes) {
        xc = new XmlClass(c.getName(), index++, true);
        result.getXmlClasses().add(xc);
    }
    return result;
}
Also used : XmlTest(org.testng.xml.XmlTest) XmlClass(org.testng.xml.XmlClass) XmlClass(org.testng.xml.XmlClass)

Example 3 with XmlTest

use of org.testng.xml.XmlTest 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 4 with XmlTest

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

Example 5 with XmlTest

use of org.testng.xml.XmlTest in project intellij-community by JetBrains.

the class IDEARemoteTestNG method run.

public void run() {
    try {
        initializeSuitesAndJarFile();
        List<XmlSuite> suites = Lists.newArrayList();
        calculateAllSuites(m_suites, suites);
        if (suites.size() > 0) {
            for (XmlSuite suite : suites) {
                final List<XmlTest> tests = suite.getTests();
                for (XmlTest test : tests) {
                    try {
                        if (myParam != null) {
                            for (XmlClass aClass : test.getXmlClasses()) {
                                List<XmlInclude> includes = new ArrayList<XmlInclude>();
                                for (XmlInclude include : aClass.getIncludedMethods()) {
                                    includes.add(new XmlInclude(include.getName(), Collections.singletonList(Integer.parseInt(myParam)), 0));
                                }
                                aClass.setIncludedMethods(includes);
                            }
                        }
                    } catch (NumberFormatException e) {
                        System.err.println("Invocation number: expected integer but found: " + myParam);
                    }
                }
            }
            attachListeners(new IDEATestNGRemoteListener());
            super.run();
            System.exit(0);
        } else {
            System.out.println("##teamcity[enteredTheMatrix]");
            System.err.println("Nothing found to run");
        }
    } catch (Throwable cause) {
        cause.printStackTrace(System.err);
    }
}
Also used : XmlInclude(org.testng.xml.XmlInclude) XmlSuite(org.testng.xml.XmlSuite) XmlTest(org.testng.xml.XmlTest) ArrayList(java.util.ArrayList) XmlClass(org.testng.xml.XmlClass)

Aggregations

XmlTest (org.testng.xml.XmlTest)16 XmlSuite (org.testng.xml.XmlSuite)12 XmlClass (org.testng.xml.XmlClass)11 XmlInclude (org.testng.xml.XmlInclude)6 ArrayList (java.util.ArrayList)3 File (java.io.File)2 List (java.util.List)2 Test (org.junit.Test)2 ParameterException (com.beust.jcommander.ParameterException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Map (java.util.Map)1 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 IDEATestNGRemoteListener (org.testng.IDEATestNGRemoteListener)1 ISuite (org.testng.ISuite)1 ITestRunnerFactory (org.testng.ITestRunnerFactory)1 TestRunner (org.testng.TestRunner)1