Java Code Examples for org.testng.TestNG#setTestSuites()
The following examples show how to use
org.testng.TestNG#setTestSuites() .
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: AllureTestListenerSuiteNameTest.java From allure1 with Apache License 2.0 | 6 votes |
@Before public void setUp() throws IOException { resultsDir = folder.newFolder(); AllureResultsUtils.setResultsDirectory(resultsDir); List<String> suites = new ArrayList<>(); URL resource = getClass().getClassLoader().getResource("suite3.xml"); assertNotNull("could not find suite3.xml", resource); //noinspection ConstantConditions suites.add(resource.getFile()); TestNG testNG = new TestNG(); testNG.setTestSuites(suites); testNG.setUseDefaultListeners(false); testNG.run(); }
Example 3
Source File: AllureTestListenerGroupsTest.java From allure1 with Apache License 2.0 | 6 votes |
@Test // see https://github.com/allure-framework/allure-core/issues/880 public void reportContainsTestForGroups() { // GIVEN: an TestNG suite with groups TestNG testNG = new TestNG(false); testNG.setTestSuites(singletonList(getClass().getClassLoader().getResource("suite-groups.xml").getFile())); // WHEN: executing testNG.run(); // THEN: report only contains results for included groups List<File> files = listTestSuiteFiles(resultsDir); assertThat(files, hasSize(1)); File file = files.get(0); TestSuiteResult result = unmarshal(file, TestSuiteResult.class); assertThat(result.getTestCases(), hasSize(2)); List<String> status = new ArrayList<>(); for (TestCaseResult test : result.getTestCases()) { status.add(test.getName() + ":" + test.getStatus()); } assertThat(status, containsInAnyOrder("inactiveIncludedTest:PENDING", "activeIncludedTest:PASSED")); }
Example 4
Source File: TestNGExecutor.java From teamengine with Apache License 2.0 | 6 votes |
/** * Sets the test suite to run using the given URI reference. Three types of * references are supported: * <ul> * <li>A file system reference</li> * <li>A file: URI</li> * <li>A jar: URI</li> * </ul> * * @param driver * The main TestNG driver. * @param ets * A URI referring to a suite definition. */ private void setTestSuites(TestNG driver, URI ets) { if (ets.getScheme().equalsIgnoreCase("jar")) { // jar:{url}!/{entry} String[] jarPath = ets.getSchemeSpecificPart().split("!"); File jarFile = new File(URI.create(jarPath[0])); driver.setTestJar(jarFile.getAbsolutePath()); driver.setXmlPathInJar(jarPath[1].substring(1)); } else { List<String> testSuites = new ArrayList<String>(); File tngFile = new File(ets); if (tngFile.exists()) { LOGR.log(Level.CONFIG, "Using TestNG config file {0}", tngFile.getAbsolutePath()); testSuites.add(tngFile.getAbsolutePath()); } else { throw new IllegalArgumentException("A valid TestNG config file reference is required."); } driver.setTestSuites(testSuites); } }
Example 5
Source File: AllureTestNgTest.java From allure-java with Apache License 2.0 | 5 votes |
@Step("Run testng suites {suites}") private AllureResults runTestNgSuites(final Consumer<TestNG> configurer, final String... suites) { final ClassLoader classLoader = getClass().getClassLoader(); List<String> suiteFiles = Arrays.stream(suites) .map(classLoader::getResource) .filter(Objects::nonNull) .map(URL::getFile) .collect(Collectors.toList()); assertThat(suites) .as("Cannot find all suite xml files") .hasSameSizeAs(suiteFiles); final AllureResultsWriterStub results = new AllureResultsWriterStub(); final AllureLifecycle lifecycle = new AllureLifecycle(results); final AllureTestNg adapter = new AllureTestNg(lifecycle); final TestNG testNg = new TestNG(false); testNg.addListener((ITestNGListener) adapter); testNg.setTestSuites(suiteFiles); configurer.accept(testNg); final AllureLifecycle cached = Allure.getLifecycle(); try { Allure.setLifecycle(lifecycle); StepsAspects.setLifecycle(lifecycle); AttachmentsAspects.setLifecycle(lifecycle); testNg.run(); } finally { Allure.setLifecycle(cached); StepsAspects.setLifecycle(cached); AttachmentsAspects.setLifecycle(cached); } return results; }
Example 6
Source File: MyTestExecutor.java From AppiumTestDistribution with GNU General Public License v3.0 | 5 votes |
public boolean runMethodParallel() { TestNG testNG = new TestNG(); List<String> suites = Lists.newArrayList(); suites.add(getProperty("user.dir") + PARALLEL_XML_LOCATION); testNG.setTestSuites(suites); testNG.run(); return testNG.hasFailure(); }
Example 7
Source File: CobarTestNGTestsRunner.java From cobarclient with Apache License 2.0 | 5 votes |
/** * @param args */ public static void main(String[] args) { BasicConfigurator.configure(); Logger.getRootLogger().setLevel(Level.INFO); TestNG testng = new TestNG(); List<String> suites = new ArrayList<String>(); suites.add("src/test/resources/testng.xml"); testng.setTestSuites(suites); testng.setOutputDirectory("target/test-output"); testng.run(); }
Example 8
Source File: AllureTestListenerMultipleSuitesTest.java From allure1 with Apache License 2.0 | 5 votes |
@Before public void setUp() throws IOException { resultsDir = Files.createTempDirectory(ALLURE_RESULTS); AllureResultsUtils.setResultsDirectory(resultsDir.toFile()); List<String> suites = Lists.newArrayList(); suites.add(getClass().getResource(SUITE1).getFile()); suites.add(getClass().getResource(SUITE2).getFile()); TestNG testNG = new TestNG(); testNG.setTestSuites(suites); testNG.setSuiteThreadPoolSize(2); testNG.setUseDefaultListeners(false); testNG.run(); }