当前位置: 首页>>代码示例>>Java>>正文


Java TestNG.setTestSuites方法代码示例

本文整理汇总了Java中org.testng.TestNG.setTestSuites方法的典型用法代码示例。如果您正苦于以下问题:Java TestNG.setTestSuites方法的具体用法?Java TestNG.setTestSuites怎么用?Java TestNG.setTestSuites使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.testng.TestNG的用法示例。


在下文中一共展示了TestNG.setTestSuites方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setTestSuites

import org.testng.TestNG; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:opengeospatial,项目名称:teamengine,代码行数:34,代码来源:TestNGExecutor.java

示例2: setUp

import org.testng.TestNG; //导入方法依赖的package包/类
@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();
}
 
开发者ID:allure-framework,项目名称:allure1,代码行数:18,代码来源:AllureTestListenerSuiteNameTest.java

示例3: reportContainsTestForGroups

import org.testng.TestNG; //导入方法依赖的package包/类
@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"));
}
 
开发者ID:allure-framework,项目名称:allure1,代码行数:22,代码来源:AllureTestListenerGroupsTest.java

示例4: runTests

import org.testng.TestNG; //导入方法依赖的package包/类
private void runTests() {
    TestNG testNg = new TestNG();
    testNg.setOutputDirectory(testReportDir.getAbsolutePath());
    testNg.setDefaultSuiteName(options.getDefaultSuiteName());
    testNg.setDefaultTestName(options.getDefaultTestName());
    testNg.setParallel(options.getParallel());
    testNg.setThreadCount(options.getThreadCount());
    invokeVerifiedMethod(testNg, "setConfigFailurePolicy", String.class, options.getConfigFailurePolicy(), TestNGOptions.DEFAULT_CONFIG_FAILURE_POLICY);
    invokeVerifiedMethod(testNg, "setPreserveOrder", boolean.class, options.getPreserveOrder(), false);
    invokeVerifiedMethod(testNg, "setGroupByInstances", boolean.class, options.getGroupByInstances(), false);
    testNg.setUseDefaultListeners(options.getUseDefaultListeners());
    testNg.setVerbose(0);
    testNg.setGroups(CollectionUtils.join(",", options.getIncludeGroups()));
    testNg.setExcludedGroups(CollectionUtils.join(",", options.getExcludeGroups()));

    //adding custom test listeners before Gradle's listeners.
    //this way, custom listeners are more powerful and, for example, they can change test status.
    for (String listenerClass : options.getListeners()) {
        try {
            testNg.addListener(applicationClassLoader.loadClass(listenerClass).newInstance());
        } catch (Throwable e) {
            throw new GradleException(String.format("Could not add a test listener with class '%s'.", listenerClass), e);
        }
    }

    if (!options.getIncludedTests().isEmpty()) {
        testNg.addListener(new SelectedTestsFilter(options.getIncludedTests()));
    }

    if (!suiteFiles.isEmpty()) {
        testNg.setTestSuites(GFileUtils.toPaths(suiteFiles));
    } else {
        testNg.setTestClasses(testClasses.toArray(new Class[0]));
    }
    testNg.addListener((Object) adaptListener(new TestNGTestResultProcessorAdapter(resultProcessor, idGenerator, timeProvider)));
    testNg.run();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:38,代码来源:TestNGTestClassProcessor.java

示例5: run

import org.testng.TestNG; //导入方法依赖的package包/类
private InvokedMethodNameListener run(final String suitePath, final Supplier<BeforeMethodListener> listenerSupplier) {
    final TestNG tng = create();

    final InvokedMethodNameListener nameListener = new InvokedMethodNameListener();
    final BeforeMethodListener spyListener = listenerSupplier.get();

    tng.addListener((ITestNGListener) nameListener);
    tng.addListener((ITestNGListener) spyListener);
    tng.setTestSuites(singletonList(suitePath));
    tng.run();

    return nameListener;
}
 
开发者ID:sskorol,项目名称:webdriver-supplier,代码行数:14,代码来源:ListenerTests.java

示例6: autoRunXml

import org.testng.TestNG; //导入方法依赖的package包/类
/**
 * This method runs the XML suite file dynamically
 **/

public static void autoRunXml() {
	List<String> files = new ArrayList<String>();
	if (Driver.getRunOn().equalsIgnoreCase("standalone")) {
		if (Driver.getType().equalsIgnoreCase("desktop")) {
			files.add("./src/test/resources/suites/desktop.xml");
		} else if (Driver.getType().equalsIgnoreCase("device")) {
			files.add("./src/test/resources/suites/device.xml");
		} else if (Driver.getType().equalsIgnoreCase("app")) {
			files.add("./src/test/resources/suites/app.xml");
		}
	} else if (Driver.getRunOn().equalsIgnoreCase("grid")) {
		if (Driver.getType().equalsIgnoreCase("desktop")) {
			files.add("./src/test/resources/suites/desktop-grid.xml");
		} else if (Driver.getType().equalsIgnoreCase("device")) {
			files.add("./src/test/resources/suites/device-grid.xml");
		} else if (Driver.getType().equalsIgnoreCase("app")) {
			files.add("./src/test/resources/suites/app.xml");
		}
	}
	TestNG tng = new TestNG();
	TestNG tng1 = new TestNG();
	tng.setOutputDirectory(ReportNGReport.makDir());
	tng1.setOutputDirectory(ExtentReport.makDir());
	tng.setUseDefaultListeners(false);
	tng.setTestSuites(files);
	tng.run();

}
 
开发者ID:AnujDasari,项目名称:Actitime-Framework,代码行数:33,代码来源:XMLUtilityManager.java

示例7: TestRun

import org.testng.TestNG; //导入方法依赖的package包/类
public TestRun(String runXmlPath, String threadName, int threadPriority,
		String resultFolderPath, RunData runData) {
	this.runXmlPath = runXmlPath;
	this.runData = runData;
	this.xmlName = threadName;
	this.setName(threadName + "_" + runData.getBrowser().toString());
	this.setPriority(threadPriority);
	this.resultFolderPath = resultFolderPath;
	runner = new TestNG();
	List<String> tempSuite = new ArrayList<String>();
	tempSuite.add(this.runXmlPath);
	runner.setTestSuites(tempSuite);
}
 
开发者ID:toolsqa,项目名称:OptimusPrime,代码行数:14,代码来源:TestRun.java

示例8: runMethodParallel

import org.testng.TestNG; //导入方法依赖的package包/类
public boolean runMethodParallel() {
    TestNG testNG = new TestNG();
    List<String> suites = Lists.newArrayList();
    suites.add(System.getProperty("user.dir") + "/target/parallel.xml");
    testNG.setTestSuites(suites);
    testNG.run();
    return testNG.hasFailure();
}
 
开发者ID:saikrishna321,项目名称:AppiumTestDistribution,代码行数:9,代码来源:MyTestExecutor.java

示例9: setupSuites

import org.testng.TestNG; //导入方法依赖的package包/类
private void setupSuites(TestNG testng) throws Exception {
    switch (itCommand) {
    case "smoketest":
        setupSmokeTest(testng, itProps.getTestTypes());
        break;
    case "fulltest":
        if (fullTestRegionIndex > -1 && fullTestRegionNumber > 0) {
            setupFullTest(testng, fullTestRegionIndex, fullTestRegionNumber);
        } else {
            LOG.info("fulltest command require integrationtest.fulltest.regindex and integrationtest.fulltest.regnum parameters!");
        }
        break;
    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;
    default:
        LOG.info("Unknown command: {}", itCommand);
        break;
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:28,代码来源:IntegrationTestApp.java

示例10: main

import org.testng.TestNG; //导入方法依赖的package包/类
/**
 * @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();
}
 
开发者ID:alibaba,项目名称:cobarclient,代码行数:16,代码来源:CobarTestNGTestsRunner.java

示例11: setUp

import org.testng.TestNG; //导入方法依赖的package包/类
@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();
}
 
开发者ID:allure-framework,项目名称:allure1,代码行数:14,代码来源:AllureTestListenerMultipleSuitesTest.java

示例12: execute

import org.testng.TestNG; //导入方法依赖的package包/类
public void execute(Test test, UUID batchId,Boolean persist) {

        DbHelper db = new DbHelper();
        try {
            String outputDir = testReport + "/" + batchId + "/" + "TestNG" + "/"+test.getName();
            System.setProperty("testReport", outputDir);
            TestListener tla = new TestListener();
            TestReporter reporter = new TestReporter();
            ArrayList<String> suiteFiles = new ArrayList<String>();
            suiteFiles.add(test.getPath());
            XmlSuite xmlSuite = new XmlSuite();
            xmlSuite.setSuiteFiles(suiteFiles);
            List suites = Lists.newArrayList();
            suites.add(test.getPath());
            TestNG testNG = new TestNG();
            testNG.addListener(tla);
            testNG.addListener(reporter);
            testNG.setTestSuites(suites);
            testNG.setOutputDirectory(outputDir);
            testNG.run();
            test.setPassed(tla.getPassedTests().size());
            test.setFailed(tla.getFailedTests().size());
            test.setException(tla.getSkippedTests().size());
            db.addResults(test, batchId, persist);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
 
开发者ID:Flipkart,项目名称:harness,代码行数:30,代码来源:TestNgRunner.java


注:本文中的org.testng.TestNG.setTestSuites方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。