本文整理汇总了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);
}
}
示例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();
}
示例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"));
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
示例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;
}
}
示例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();
}
示例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();
}
示例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();
}
}