Search in sources :

Example 1 with XmlInclude

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

the class SimpleBaseTest method addMethods.

protected void addMethods(XmlClass cls, String... methods) {
    int index = 0;
    for (String m : methods) {
        XmlInclude include = new XmlInclude(m, index++);
        cls.getIncludedMethods().add(include);
    }
}
Also used : XmlInclude(org.testng.xml.XmlInclude)

Example 2 with XmlInclude

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

Example 3 with XmlInclude

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

the class TestNGXmlSuiteHelper method writeSuite.

public static File writeSuite(Map<String, Map<String, List<String>>> map, Map<String, String> testParams, String name, String rootPath, Logger logger) {
    File xmlFile;
    final XmlSuite xmlSuite = new XmlSuite();
    xmlSuite.setParameters(testParams);
    XmlTest xmlTest = new XmlTest(xmlSuite);
    xmlTest.setName(name);
    List<XmlClass> xmlClasses = new ArrayList<XmlClass>();
    int idx = 0;
    for (String className : map.keySet()) {
        final XmlClass xmlClass = new XmlClass(className, idx++, false);
        final Map<String, List<String>> collection = map.get(className);
        if (collection != null) {
            final ArrayList<XmlInclude> includedMethods = new ArrayList<XmlInclude>();
            int mIdx = 0;
            for (String methodName : collection.keySet()) {
                final List<Integer> includes = new ArrayList<Integer>();
                for (String include : collection.get(methodName)) {
                    try {
                        includes.add(Integer.parseInt(include));
                    } catch (NumberFormatException e) {
                        logger.log(e);
                    }
                }
                includedMethods.add(new XmlInclude(methodName, includes, mIdx++));
            }
            xmlClass.setIncludedMethods(includedMethods);
        }
        xmlClasses.add(xmlClass);
    }
    xmlTest.setXmlClasses(xmlClasses);
    xmlFile = new File(rootPath, "temp-testng-customsuite.xml");
    final String toXml = xmlSuite.toXml();
    writeToFile(logger, xmlFile, toXml);
    return xmlFile;
}
Also used : XmlSuite(org.testng.xml.XmlSuite) ArrayList(java.util.ArrayList) XmlInclude(org.testng.xml.XmlInclude) XmlTest(org.testng.xml.XmlTest) List(java.util.List) ArrayList(java.util.ArrayList) File(java.io.File) XmlClass(org.testng.xml.XmlClass)

Example 4 with XmlInclude

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

the class TestNGTreeHierarchyTest method testOneTestMethodWithMultipleInvocationCount.

@Test
public void testOneTestMethodWithMultipleInvocationCount() throws Exception {
    final XmlSuite suite = new XmlSuite();
    final XmlTest test = new XmlTest();
    final XmlClass xmlClass = new XmlClass("a.ATest", false);
    xmlClass.getIncludedMethods().add(new XmlInclude("test1", Arrays.asList(0, 1, 2), 0));
    test.getClasses().add(xmlClass);
    suite.getTests().add(test);
    doTest(suite, "##teamcity[enteredTheMatrix]\n" + "\n" + "##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://a.ATest']\n" + "\n" + "##teamcity[testStarted name='ATest.test1|[0|]' locationHint='java:test://a.ATest.test1|[0|]']\n" + "\n" + "##teamcity[testFinished name='ATest.test1|[0|]']\n" + "\n" + "##teamcity[testStarted name='ATest.test1|[1|] (1)' locationHint='java:test://a.ATest.test1|[1|]']\n" + "\n" + "##teamcity[testFinished name='ATest.test1|[1|] (1)']\n" + "\n" + "##teamcity[testStarted name='ATest.test1|[2|] (2)' locationHint='java:test://a.ATest.test1|[2|]']\n" + "\n" + "##teamcity[testFinished name='ATest.test1|[2|] (2)']\n");
}
Also used : XmlInclude(org.testng.xml.XmlInclude) XmlSuite(org.testng.xml.XmlSuite) XmlTest(org.testng.xml.XmlTest) XmlClass(org.testng.xml.XmlClass) Test(org.junit.Test) XmlTest(org.testng.xml.XmlTest)

Example 5 with XmlInclude

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

the class TestNGTreeHierarchyTest method testOneTestMethod.

@Test
public void testOneTestMethod() throws Exception {
    final XmlSuite suite = new XmlSuite();
    final XmlTest test = new XmlTest();
    final XmlClass xmlClass = new XmlClass("a.ATest", false);
    xmlClass.getIncludedMethods().add(new XmlInclude("test1"));
    test.getClasses().add(xmlClass);
    suite.getTests().add(test);
    doTest(suite, "##teamcity[enteredTheMatrix]\n" + "\n" + "##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://a.ATest']\n" + "\n" + "##teamcity[testStarted name='ATest.test1|[0|]' locationHint='java:test://a.ATest.test1|[0|]']\n" + "\n" + "##teamcity[testFinished name='ATest.test1|[0|]']\n");
}
Also used : XmlInclude(org.testng.xml.XmlInclude) XmlSuite(org.testng.xml.XmlSuite) XmlTest(org.testng.xml.XmlTest) XmlClass(org.testng.xml.XmlClass) Test(org.junit.Test) XmlTest(org.testng.xml.XmlTest)

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