Java Code Examples for org.testng.xml.XmlSuite#setParallel()

The following examples show how to use org.testng.xml.XmlSuite#setParallel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyTestExecutor.java    From AppiumTestDistribution with GNU General Public License v3.0 6 votes vote down vote up
public XmlSuite constructXmlSuiteForDistribution(List<String> tests,
                                                 Map<String, List<Method>> methods,
                                                 String suiteName,
                                                 String category,
                                                 int deviceCount) {
    XmlSuite suite = new XmlSuite();
    suite.setName(suiteName);
    suite.setThreadCount(deviceCount);
    suite.setParallel(ParallelMode.CLASSES);
    suite.setVerbose(2);
    listeners.add("com.appium.manager.AppiumParallelMethodTestListener");
    listeners.add("com.appium.utils.RetryListener");
    include(listeners, LISTENERS);
    suite.setListeners(listeners);
    XmlTest test = new XmlTest(suite);
    test.setName(category);
    test.addParameter("device", "");
    include(groupsExclude, EXCLUDE_GROUPS);
    include(groupsInclude, INCLUDE_GROUPS);
    test.setIncludedGroups(groupsInclude);
    test.setExcludedGroups(groupsExclude);
    List<XmlClass> xmlClasses = writeXmlClass(tests, methods);
    test.setXmlClasses(xmlClasses);
    writeTestNGFile(suite);
    return suite;
}
 
Example 2
Source File: MyTestExecutor.java    From AppiumTestDistribution with GNU General Public License v3.0 6 votes vote down vote up
public XmlSuite constructXmlSuiteForParallelCucumber(
    int deviceCount, List<AppiumDevice> deviceSerail) {
    ArrayList<String> listeners = new ArrayList<>();
    listeners.add("com.cucumber.listener.CucumberListener");
    XmlSuite suite = new XmlSuite();
    suite.setName("TestNG Forum");
    suite.setThreadCount(deviceCount);
    suite.setParallel(ParallelMode.TESTS);
    suite.setVerbose(2);
    suite.setListeners(listeners);
    for (int i = 0; i < deviceCount; i++) {
        XmlTest test = new XmlTest(suite);
        test.setName("TestNG Test" + i);
        test.setPreserveOrder(false);
        test.addParameter("device", deviceSerail.get(i).getDevice().getUdid());
        test.setPackages(getPackages());
    }
    return getXmlSuite(suite);
}
 
Example 3
Source File: MyTestExecutor.java    From AppiumTestDistribution with GNU General Public License v3.0 5 votes vote down vote up
public XmlSuite constructXmlSuiteForParallel(String pack, List<String> testcases,
                                             Map<String, List<Method>> methods,
                                             String suiteName, String category,
                                             int deviceCount,
                                             List<AppiumDevice> deviceSerail) {
    ArrayList<String> listeners = new ArrayList<>();
    listeners.add("com.appium.manager.AppiumParallelTestListener");
    listeners.add("com.appium.utils.RetryListener");
    include(listeners, LISTENERS);
    include(groupsInclude, INCLUDE_GROUPS);
    include(groupsExclude, EXCLUDE_GROUPS);
    XmlSuite suite = new XmlSuite();
    suite.setName(suiteName);
    suite.setThreadCount(deviceCount);
    suite.setDataProviderThreadCount(deviceCount);
    suite.setParallel(ParallelMode.TESTS);
    suite.setVerbose(2);
    suite.setListeners(listeners);
    for (int i = 0; i < deviceCount; i++) {
        XmlTest test = new XmlTest(suite);
        test.setName(category + "-" + i);
        test.setPreserveOrder(false);
        test.addParameter("device", deviceSerail.get(i).getDevice().getUdid());
        test.addParameter("hostName", deviceSerail.get(i).getHostName());
        test.setIncludedGroups(groupsInclude);
        test.setExcludedGroups(groupsExclude);
        List<XmlClass> xmlClasses = writeXmlClass(testcases, methods);
        test.setXmlClasses(xmlClasses);
    }
    writeTestNGFile(suite);
    return suite;
}
 
Example 4
Source File: MyTestExecutor.java    From AppiumTestDistribution with GNU General Public License v3.0 5 votes vote down vote up
public XmlSuite constructXmlSuiteForDistributionMethods(List<String> tests,
                                                        Map<String, List<Method>> methods,
                                                        String suiteName,
                                                        String category,
                                                        int deviceCount) {
    include(groupsInclude, INCLUDE_GROUPS);
    XmlSuite suite = new XmlSuite();
    suite.setName(suiteName);
    suite.setThreadCount(deviceCount);
    suite.setDataProviderThreadCount(deviceCount);
    suite.setVerbose(2);
    suite.setParallel(ParallelMode.METHODS);
    listeners.add("com.appium.manager.AppiumParallelMethodTestListener");
    listeners.add("com.appium.utils.RetryListener");
    include(listeners, LISTENERS);
    suite.setListeners(listeners);
    CreateGroups createGroups = new CreateGroups(tests, methods, category, suite).invoke();
    List<XmlClass> xmlClasses = createGroups.getXmlClasses();
    XmlTest test = createGroups.getTest();
    List<XmlClass> writeXml = createGroups.getWriteXml();
    for (XmlClass xmlClass : xmlClasses) {
        writeXml.add(new XmlClass(xmlClass.getName()));
        test.setClasses(writeXml);
    }
    writeTestNGFile(suite);
    return suite;
}
 
Example 5
Source File: MyTestExecutor.java    From AppiumTestDistribution with GNU General Public License v3.0 5 votes vote down vote up
public XmlSuite constructXmlSuiteDistributeCucumber(int deviceCount) {
    ArrayList<String> listeners = new ArrayList<>();
    listeners.add("com.cucumber.listener.CucumberListener");
    XmlSuite suite = new XmlSuite();
    suite.setName("TestNG Forum");
    suite.setThreadCount(deviceCount);
    suite.setParallel(ParallelMode.CLASSES);
    suite.setVerbose(2);
    suite.setListeners(listeners);
    XmlTest test = new XmlTest(suite);
    test.setName("TestNG Test");
    test.addParameter("device", "");
    test.setPackages(getPackages());
    return getXmlSuite(suite);
}
 
Example 6
Source File: IntegrationTestApp.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private XmlSuite loadSuite(String suitePath, InputStreamSource resource) throws IOException {
    IFileParser<XmlSuite> parser = getParser(suitePath);
    try (InputStream inputStream = resource.getInputStream()) {
        XmlSuite xmlSuite = parser.parse(suitePath, inputStream, true);
        xmlSuite.setParallel(XmlSuite.ParallelMode.getValidParallel(parallel));
        xmlSuite.setThreadCount(threadCount);
        xmlSuite.setTimeOut(timeOut);
        LOG.info("Test are running in: {} type of parallel mode, thread count: {} and with test timeout: {}", parallel.toUpperCase(), threadCount, timeOut);
        return xmlSuite;
    }
}