org.testng.xml.XmlSuite Java Examples

The following examples show how to use org.testng.xml.XmlSuite. 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: ExtentIReporterSuiteClassListenerAdapter.java    From extentreports-testng-adapter with Apache License 2.0 7 votes vote down vote up
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
    ExtentService.getInstance().setReportUsesManualConfiguration(true);
    ExtentService.getInstance().setAnalysisStrategy(AnalysisStrategy.SUITE);

    for (ISuite suite : suites) {
        Map<String, ISuiteResult> result = suite.getResults();

        for (ISuiteResult r : result.values()) {
            ITestContext context = r.getTestContext();

            ExtentTest suiteTest = ExtentService.getInstance().createTest(r.getTestContext().getSuite().getName());
            buildTestNodes(suiteTest, context.getFailedTests(), Status.FAIL);
            buildTestNodes(suiteTest, context.getSkippedTests(), Status.SKIP);
            buildTestNodes(suiteTest, context.getPassedTests(), Status.PASS);
        }
    }

    for (String s : Reporter.getOutput()) {
        ExtentService.getInstance().setTestRunnerOutput(s);
    }

    ExtentService.getInstance().flush();
}
 
Example #2
Source File: ArkTestNGAlterSuiteListener.java    From sofa-ark with Apache License 2.0 6 votes vote down vote up
protected void resetSingleXmlSuite(XmlSuite suite) {
    for (XmlTest xmlTest : suite.getTests()) {
        for (XmlClass xmlClass : xmlTest.getClasses()) {
            Class testClass = xmlClass.getSupportClass();
            if (testClass.getAnnotation(TestNGOnArk.class) != null) {
                if (!DelegateArkContainer.isStarted()) {
                    DelegateArkContainer.launch(testClass);
                }

                try {
                    xmlClass.setClass(DelegateArkContainer.getTestClassLoader().loadClass(
                        testClass.getCanonicalName()));
                } catch (ClassNotFoundException ex) {
                    throw new ArkRuntimeException(String.format(
                        "Load testNG test class %s failed.", testClass.getCanonicalName()), ex);
                }
            }
        }
    }
}
 
Example #3
Source File: TestNGTestUnit.java    From pitest with Apache License 2.0 6 votes vote down vote up
private void executeInCurrentLoader(final ResultCollector rc) {
  final TestNGAdapter listener = new TestNGAdapter(this.clazz,
      this.getDescription(), rc);

  final XmlSuite suite = createSuite();

  TESTNG.setDefaultSuiteName(suite.getName());
  TESTNG.setXmlSuites(Collections.singletonList(suite));

  LISTENER.setChild(listener);
  try {
    TESTNG.run();
  } finally {
    // yes this is hideous
    LISTENER.setChild(null);
  }
}
 
Example #4
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.Fixtures
@Test(description = "Suite fixtures", dataProvider = "parallelConfiguration")
public void perSuiteFixtures(final XmlSuite.ParallelMode mode, final int threadCount) {
    String suiteName = "Test suite 12";
    String testTagName = "Test tag 12";
    String before1 = "beforeSuite1";
    String before2 = "beforeSuite2";
    String after1 = "afterSuite1";
    String after2 = "afterSuite2";

    final AllureResults results = runTestNgSuites(
            parallel(mode, threadCount),
            "suites/per-suite-fixtures-combination.xml"
    );

    List<TestResult> testResult = results.getTestResults();
    List<TestResultContainer> testContainers = results.getTestResultContainers();

    assertThat(testResult).as("Unexpected quantity of testng case results has been written").hasSize(1);
    List<String> testUuid = singletonList(testResult.get(0).getUuid());

    assertContainersChildren(testTagName, testContainers, testUuid);
    assertContainersChildren(suiteName, testContainers, getUidsByName(testContainers, testTagName));
    assertBeforeFixtures(suiteName, testContainers, before1, before2);
    assertAfterFixtures(suiteName, testContainers, after1, after2);
}
 
Example #5
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@AllureFeatures.Descriptions
@Test(description = "Javadoc description of befores", dataProvider = "parallelConfiguration")
public void descriptionsBefores(final XmlSuite.ParallelMode mode, final int threadCount) {
    final String beforeClassDescription = "Before class description";
    final String beforeMethodDescription = "Before method description";
    final AllureResults results = runTestNgSuites(
            parallel(mode, threadCount),
            "suites/descriptions-test.xml"
    );
    final List<TestResultContainer> testContainers = results.getTestResultContainers();

    assertThat(testContainers).as("Test containers has not been written")
            .isNotEmpty()
            .filteredOn(container -> !container.getBefores().isEmpty())
            .extracting(container -> container.getBefores().get(0).getDescriptionHtml().trim())
            .as("Javadoc description of befores have not been processed")
            .containsOnly(beforeClassDescription, beforeMethodDescription);
}
 
Example #6
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@AllureFeatures.Fixtures
@Issue("304")
@Test(dataProvider = "parallelConfiguration")
public void shouldProcessFailedSetUps(final XmlSuite.ParallelMode mode, final int threadCount) {
    final AllureResults results = runTestNgSuites(parallel(mode, threadCount), "suites/gh-304.xml");

    assertThat(results.getTestResults())
            .extracting(TestResult::getName, TestResult::getStatus)
            .contains(tuple("skippedTest", Status.SKIPPED));

    assertThat(results.getTestResultContainers())
            .flatExtracting(TestResultContainer::getAfters)
            .extracting(FixtureResult::getName, FixtureResult::getStatus)
            .contains(tuple("afterAlways", Status.PASSED));

    assertThat(results.getTestResultContainers())
            .flatExtracting(TestResultContainer::getAfters)
            .filteredOn("name", "afterAlways")
            .flatExtracting(FixtureResult::getSteps)
            .extracting(StepResult::getName)
            .containsExactly(
                    "first", "second"
            );
}
 
Example #7
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@DataProvider(name = "parallelConfiguration")
public static Object[][] parallelConfiguration() {
    return new Object[][]{
            new Object[]{XmlSuite.ParallelMode.NONE, 10},
            new Object[]{XmlSuite.ParallelMode.NONE, 5},
            new Object[]{XmlSuite.ParallelMode.NONE, 2},
            new Object[]{XmlSuite.ParallelMode.NONE, 1},
            new Object[]{XmlSuite.ParallelMode.METHODS, 10},
            new Object[]{XmlSuite.ParallelMode.METHODS, 5},
            new Object[]{XmlSuite.ParallelMode.METHODS, 2},
            new Object[]{XmlSuite.ParallelMode.METHODS, 1},
            new Object[]{XmlSuite.ParallelMode.CLASSES, 10},
            new Object[]{XmlSuite.ParallelMode.CLASSES, 5},
            new Object[]{XmlSuite.ParallelMode.CLASSES, 2},
            new Object[]{XmlSuite.ParallelMode.CLASSES, 1},
            new Object[]{XmlSuite.ParallelMode.INSTANCES, 10},
            new Object[]{XmlSuite.ParallelMode.INSTANCES, 5},
            new Object[]{XmlSuite.ParallelMode.INSTANCES, 2},
            new Object[]{XmlSuite.ParallelMode.INSTANCES, 1},
            new Object[]{XmlSuite.ParallelMode.TESTS, 10},
            new Object[]{XmlSuite.ParallelMode.TESTS, 5},
            new Object[]{XmlSuite.ParallelMode.TESTS, 2},
            new Object[]{XmlSuite.ParallelMode.TESTS, 1},
    };
}
 
Example #8
Source File: CarinaListener.java    From carina with Apache License 2.0 6 votes vote down vote up
protected String getTitle(XmlSuite suite) {
    String browser = getBrowser();
    if (!browser.isEmpty()) {
        browser = " " + browser; // insert the space before
    }
    String device = getDeviceName();

    String env = !Configuration.isNull(Parameter.ENV) ? Configuration.get(Parameter.ENV)
            : Configuration.get(Parameter.URL);

    String title = "";
    String app_version = "";

    if (!Configuration.get(Parameter.APP_VERSION).isEmpty()) {
        // if nothing is specified then title will contain nothing
        app_version = Configuration.get(Parameter.APP_VERSION) + " - ";
    }

    String suiteName = getSuiteName(suite);
    String xmlFile = getSuiteFileName(suite);

    title = String.format(SUITE_TITLE, app_version, suiteName, String.format(XML_SUITE_NAME, xmlFile), env, device,
            browser);

    return title;
}
 
Example #9
Source File: ExtentIReporterSuiteListenerAdapter.java    From extentreports-testng-adapter with Apache License 2.0 6 votes vote down vote up
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
    ExtentService.getInstance().setReportUsesManualConfiguration(true);
    ExtentService.getInstance().setAnalysisStrategy(AnalysisStrategy.SUITE);

    for (ISuite suite : suites) {
        Map<String, ISuiteResult> result = suite.getResults();

        for (ISuiteResult r : result.values()) {
            ITestContext context = r.getTestContext();

            ExtentTest suiteTest = ExtentService.getInstance().createTest(r.getTestContext().getSuite().getName());
            buildTestNodes(suiteTest, context.getFailedTests(), Status.FAIL);
            buildTestNodes(suiteTest, context.getSkippedTests(), Status.SKIP);
            buildTestNodes(suiteTest, context.getPassedTests(), Status.PASS);
        }
    }

    for (String s : Reporter.getOutput()) {
        ExtentService.getInstance().setTestRunnerOutput(s);
    }

    ExtentService.getInstance().flush();
}
 
Example #10
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 #11
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.Fixtures
@Test(description = "Test fixtures", dataProvider = "parallelConfiguration")
public void perTestTagFixtures(final XmlSuite.ParallelMode mode, final int threadCount) {
    String suiteName = "Test suite 13";
    String testTagName = "Test tag 13";
    String before1 = "beforeTest1";
    String before2 = "beforeTest2";
    String after1 = "afterTest1";
    String after2 = "afterTest2";

    final AllureResults results = runTestNgSuites(
            parallel(mode, threadCount),
            "suites/per-test-tag-fixtures-combination.xml"
    );

    List<TestResult> testResult = results.getTestResults();
    List<TestResultContainer> testContainers = results.getTestResultContainers();

    assertThat(testResult).as("Unexpected quantity of testng case results has been written").hasSize(1);
    List<String> testUuid = singletonList(testResult.get(0).getUuid());

    assertContainersChildren(testTagName, testContainers, testUuid);
    assertContainersChildren(suiteName, testContainers, getUidsByName(testContainers, testTagName));
    assertBeforeFixtures(testTagName, testContainers, before1, before2);
    assertAfterFixtures(testTagName, testContainers, after1, after2);
}
 
Example #12
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 #13
Source File: AtsReportListener.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
@Override
public void generateReport(
                            List<XmlSuite> arg0,
                            List<ISuite> arg1,
                            String arg2 ) {

    //we just need the report format, that why we set other fields null
    ReportFormatter reportFormatter = new ReportFormatter(ReportAppender.getRuns(),
                                                          mailSubjectFormat,
                                                          null,
                                                          null,
                                                          0,
                                                          null);
    // send report by mail
    MailReportSender mailReportSender = new MailReportSender(reportFormatter.getDescription(),
                                                             reportFormatter.toHtml());
    mailReportSender.send();

}
 
Example #14
Source File: ExtentTestNGIReporterListener.java    From Selenium-Framework-Design-in-Data-Driven-Testing with MIT License 6 votes vote down vote up
/**
 * generateReport method
 *
 * @param xmlSuites
 * @param suites
 * @param outputDirectory
 */
@Override
public void generateReport(List<XmlSuite> xmlSuites,
                           List<ISuite> suites,
                           String outputDirectory) {

    for (ISuite suite : suites) {
        init(suite);
        Map<String, ISuiteResult> results = suite.getResults();

        for ( ISuiteResult result : results.values() ) {
            try {
                processTestResults(result);

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    extent.flush();
}
 
Example #15
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@AllureFeatures.Fixtures
@Issue("67")
@Test(description = "Should set correct status for failed after fixtures")
public void shouldSetCorrectStatusForFailedAfterFixtures() {
    final Consumer<TestNG> configurer = parallel(XmlSuite.ParallelMode.METHODS, 5);

    final AllureResults results = runTestNgSuites(
            configurer,
            "suites/failed-after-suite-fixture.xml",
            "suites/failed-after-test-fixture.xml",
            "suites/failed-after-method-fixture.xml"
    );

    assertThat(results.getTestResultContainers())
            .flatExtracting(TestResultContainer::getAfters)
            .hasSize(3)
            .extracting(FixtureResult::getName, FixtureResult::getStatus)
            .containsExactlyInAnyOrder(
                    Tuple.tuple("afterSuite", Status.BROKEN),
                    Tuple.tuple("afterTest", Status.BROKEN),
                    Tuple.tuple("afterMethod", Status.BROKEN)
            );
}
 
Example #16
Source File: AlterSuiteParametersListener.java    From teamengine with Apache License 2.0 6 votes vote down vote up
/**
 * Adds the entries from the properties document to the set of test suite
 * parameters. An entry is skipped if its value is an empty string.
 */
@Override
public void alter(List<XmlSuite> xmlSuites) {
    if (null == this.testRunArgs || this.testRunArgs.getElementsByTagName("entry").getLength() == 0) {
        return;
    }
    for (XmlSuite xmlSuite : xmlSuites) {
        Map<String, String> params = xmlSuite.getParameters();
        NodeList entries = this.testRunArgs.getElementsByTagName("entry");
        for (int i = 0; i < entries.getLength(); i++) {
            Element entry = (Element) entries.item(i);
            String value = entry.getTextContent().trim();
            if (value.isEmpty()) {
                continue;
            }
            params.put(entry.getAttribute("key"), value);
            LOGR.log(Level.FINE, "Added parameter: {0}={1}", new Object[] { entry.getAttribute("key"), value });
        }
        params.put("uuid", this.testRunId.toString());
    }
}
 
Example #17
Source File: LogLevelChangeListener.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
@Override
public void alter(List<XmlSuite> suites) {
    List<XmlSuite> cloned = new ArrayList<>(suites);
    suites.clear();

    for (XmlSuite suite : cloned) {
        String logLevels = suite.getParameter(LOG_LEVELS_PARAM_NAME);
        if (StringUtils.isNotEmpty(logLevels)) {
            List<XmlSuite> newSuites = createSuites(logLevels, suite);
            if (!newSuites.isEmpty()) {
                suites.addAll(newSuites);
            }
        } else {
            suites.add(suite);
        }
    }
}
 
Example #18
Source File: BaseTest.java    From video-recorder-java with MIT License 6 votes vote down vote up
protected ITestResult prepareMock(Class<?> tClass, Method method) {
  ITestResult result = mock(ITestResult.class);
  IClass clazz = mock(IClass.class);
  ITestNGMethod testNGMethod = mock(ITestNGMethod.class);
  ConstructorOrMethod cm = mock(ConstructorOrMethod.class);
  String methodName = method.getName();
  when(result.getTestClass()).thenReturn(clazz);
  when(result.getTestClass().getRealClass()).thenReturn(tClass);
  when(clazz.getName()).thenReturn(this.getClass().getName());
  when(result.getMethod()).thenReturn(testNGMethod);
  when(cm.getMethod()).thenReturn(method);
  when(result.getMethod().getConstructorOrMethod()).thenReturn(cm);
  when(testNGMethod.getMethodName()).thenReturn(methodName);
  ITestContext context = mock(ITestContext.class);
  when(result.getTestContext()).thenReturn(context);
  XmlTest xmlTest = new XmlTest();
  XmlSuite suite = new XmlSuite();
  xmlTest.setXmlSuite(suite);
  suite.setListeners(Arrays.asList(VideoListener.class.getName()));
  when(context.getCurrentXmlTest()).thenReturn(xmlTest);
  return result;
}
 
Example #19
Source File: AllureTestListenerConfigMethodsTest.java    From allure1 with Apache License 2.0 5 votes vote down vote up
private static XmlSuite createSuite(String testName) {
    XmlSuite suite = new XmlSuite();
    suite.setName(SUITE_PREFIX + testName);
    XmlTest test = new XmlTest(suite);
    test.setName(testName);
    List<XmlClass> classes = new ArrayList<>();
    classes.add(new XmlClass(ConfigMethodsTest.class));
    test.setXmlClasses(classes);
    return suite;
}
 
Example #20
Source File: IntegrationTestApp.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private List<XmlSuite> loadSuites(Iterable<String> suitePaths) throws IOException {
    List<XmlSuite> suites = new ArrayList<>();
    for (String suitePath : suitePaths) {
        suites.add(loadSuite(suitePath));
    }
    LOG.info("parsed suites: {}", suites.size());
    return suites;
}
 
Example #21
Source File: AllureTestListenerConfigMethodsTest.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUp() throws IOException {
    resultsDir = Files.createTempDirectory(ALLURE_RESULTS);
    AllureResultsUtils.setResultsDirectory(resultsDir.toFile());

    List<XmlSuite> suites = new ArrayList<>();
    for (ConfigMethodType type : ConfigMethodType.values()) {
        suites.add(createSuite(type.getTitle()));
    }

    TestNG testNG = new TestNG();
    testNG.setXmlSuites(suites);
    testNG.setUseDefaultListeners(false);
    testNG.run();
}
 
Example #22
Source File: BaseHTMLReporter.java    From at.info-knowledge-base with MIT License 5 votes vote down vote up
@Override
public void generateReport(final List<XmlSuite> xmlSuites, final List<ISuite> suites, final String outputDirectory) {
    try {
        final Mustache mustache = new DefaultMustacheFactory().compile(REPORT_TEMPLATE);
        final File reportsFolder = new File(outputDirectory + "/html");

        reportsFolder.mkdir();

        if (reportsFolder.exists()) {
            mustache.execute(new FileWriter(outputDirectory + "/" + REPORT_OUTPUT), getScope(suites)).flush();
        }
    } catch (Exception e) {
        LOGGER.severe("Can't create template: " + e.getMessage());
    }
}
 
Example #23
Source File: CustomHTMLReporter.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectoryName) {
    try {
        super.generateReport(xmlSuites, suites, outputDirectoryName);
        boolean onlyFailures = "true".equals(System.getProperty(ONLY_FAILURES_PROPERTY, "false"));
        File outputDirectory = new File(outputDirectoryName, REPORT_DIRECTORY);
        createCustomResults(suites, outputDirectory, onlyFailures);
    } catch (Exception ex) {
        throw new ReportNGException("Failed generating HTML report.", ex);
    }

}
 
Example #24
Source File: TestRunner.java    From qaf with MIT License 5 votes vote down vote up
/**
 * Create a list of workers to run the methods passed in parameter.
 * Each test method is run in its own worker except in the following cases:
 * - The method belongs to a class that has @Test(sequential=true)
 * - The parallel attribute is set to "classes"
 * In both these cases, all the methods belonging to that class will then
 * be put in the same worker in order to run in the same thread.
 */
@Override
public List<IWorker<ITestNGMethod>> createWorkers(List<ITestNGMethod> methods) {
  List<IWorker<ITestNGMethod>> result;
  if (XmlSuite.ParallelMode.INSTANCES.equals(m_xmlTest.getParallel())) {
    result = createInstanceBasedParallelWorkers(methods);
  } else {
    result = createClassBasedParallelWorkers(methods);
  }
  return result;
}
 
Example #25
Source File: CustomisedReports.java    From tutorials with MIT License 5 votes vote down vote up
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
    String reportTemplate = initReportTemplate();

    final String body = suites
      .stream()
      .flatMap(suiteToResults())
      .collect(Collectors.joining());

    saveReportTemplate(outputDirectory, reportTemplate.replaceFirst("</tbody>", String.format("%s</tbody>", body)));
}
 
Example #26
Source File: IntegrationTestApp.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private IFileParser<XmlSuite> getParser(String fileName) {
    IFileParser<XmlSuite> result = DEFAULT_FILE_PARSER;
    if (fileName.endsWith("xml")) {
        result = XML_PARSER;
    } else if (fileName.endsWith("yaml") || fileName.endsWith("yml")) {
        result = YAML_PARSER;
    }
    return result;
}
 
Example #27
Source File: MyTestExecutor.java    From AppiumTestDistribution with GNU General Public License v3.0 5 votes vote down vote up
private void writeTestNGFile(XmlSuite suite) {
    try (FileWriter writer = new FileWriter(new File(
        getProperty("user.dir") + PARALLEL_XML_LOCATION))) {
        writer.write(suite.toXml());
        writer.flush();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #28
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 #29
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 #30
Source File: VerifyEarlReporter.java    From teamengine with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpClass() throws Exception {
    testContext = mock(ITestContext.class);
    suite = mock(ISuite.class);
    when(suite.getName()).thenReturn("abc20-1.0");
    when(testContext.getSuite()).thenReturn(suite);
    xmlSuite = mock(XmlSuite.class);
    when(suite.getXmlSuite()).thenReturn(xmlSuite);
}