Java Code Examples for org.testng.TestNG#setXmlSuites()
The following examples show how to use
org.testng.TestNG#setXmlSuites() .
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: IntegrationTestApp.java From cloudbreak with Apache License 2.0 | 6 votes |
private void setupSuites(TestNG testng) throws Exception { switch (itCommand) { case "suites": List<String> suiteFiles = itProps.getSuiteFiles(); if (!CollectionUtils.isEmpty(suiteFiles)) { testng.setTestSuites(suiteFiles); } break; case "suiteurls": List<String> suitePathes = itProps.getSuiteFiles(); testng.setXmlSuites(loadSuites(suitePathes)); break; case CLEANUP_COMMAND: cleanupUtil.cleanupDistroxes(); cleanupUtil.cleanupSdxes(); cleanupUtil.cleanupEnvironments(); cleanupUtil.cleanupCredentials(); break; default: LOG.info("Unknown command: {}", itCommand); break; } }
Example 2
Source File: AllureTestListenerConfigMethodsTest.java From allure1 with Apache License 2.0 | 5 votes |
@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 3
Source File: CarinaListener.java From carina with Apache License 2.0 | 4 votes |
private void checkHealth(ISuite suite, String className, String[] methods) { if (className.isEmpty()) { return; } // create runtime XML suite for health check XmlSuite xmlSuite = new XmlSuite(); xmlSuite.setName("HealthCheck XmlSuite - " + className); XmlTest xmlTest = new XmlTest(xmlSuite); xmlTest.setName("HealthCheck TestCase"); XmlClass xmlHealthCheckClass = new XmlClass(); xmlHealthCheckClass.setName(className); // TestNG do not execute missed methods so we have to calulate expected // methods count to handle potential mistakes in methods naming int expectedMethodsCount = -1; if (methods != null) { // declare particular methods if they are provided List<XmlInclude> methodsToRun = constructIncludes(methods); expectedMethodsCount = methodsToRun.size(); xmlHealthCheckClass.setIncludedMethods(methodsToRun); } xmlTest.setXmlClasses(Arrays.asList(new XmlClass[] { xmlHealthCheckClass })); xmlSuite.setTests(Arrays.asList(new XmlTest[] { xmlTest })); LOGGER.info("HealthCheck '" + className + "' is started."); LOGGER.debug("HealthCheck suite content:" + xmlSuite.toXml()); // Second TestNG process to run HealthCheck TestNG testng = new TestNG(); testng.setXmlSuites(Arrays.asList(xmlSuite)); TestListenerAdapter tla = new TestListenerAdapter(); testng.addListener(tla); testng.run(); synchronized (this) { boolean passed = false; if (expectedMethodsCount == -1) { if (tla.getPassedTests().size() > 0 && tla.getFailedTests().size() == 0 && tla.getSkippedTests().size() == 0) { passed = true; } } else { LOGGER.info("Expected passed tests count: " + expectedMethodsCount); if (tla.getPassedTests().size() == expectedMethodsCount && tla.getFailedTests().size() == 0 && tla.getSkippedTests().size() == 0) { passed = true; } } if (passed) { LOGGER.info("HealthCheck suite '" + className + "' is finished successfully."); } else { throw new SkipException("Skip test(s) due to health check failures for '" + className + "'"); } } }