本文整理了Java中org.testng.TestNG.setXmlSuites()
方法的一些代码示例,展示了TestNG.setXmlSuites()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestNG.setXmlSuites()
方法的具体详情如下:
包路径:org.testng.TestNG
类名称:TestNG
方法名:setXmlSuites
[英]Specifies the XmlSuite objects to run.
[中]指定要运行的XmlSuite对象。
代码示例来源:origin: cbeust/testng
protected static TestNG create(List<XmlSuite> suites) {
TestNG result = create();
result.setXmlSuites(suites);
return result;
}
代码示例来源:origin: cbeust/testng
public static TestNG createTestNG(XmlSuite suite, Path outputDir) {
TestNG result = createTestNG(outputDir);
result.setXmlSuites(Collections.singletonList(suite));
return result;
}
代码示例来源:origin: cbeust/testng
public static void main(String[] args) throws Exception {
TestNG tng = new TestNG();
String xml =
"<suite name=\"dgf\" verbose=\"10\"><test name=\"dgf\"><classes>"
+ "<class name=\"test.dependent.MissingMethodSampleTest\"/>"
+ "</classes></test></suite>";
System.out.println(xml);
ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes());
tng.setXmlSuites(new Parser(is).parseToList());
tng.run();
}
}
代码示例来源:origin: cbeust/testng
@Test(description = "Fix for https://github.com/cbeust/testng/issues/92")
public void BeforeTestShouldRunOnce() {
XmlSuite s = createXmlSuite("Bug92");
XmlTest t =
createXmlTest(s, "Bug92 test", TestAlpha.class.getName(), TestBravo.class.getName());
s.setTests(Collections.singletonList(t));
TestNG tng = create();
tng.setXmlSuites(Collections.singletonList(s));
TestBase.beforeTestCount = 0;
TestBase.beforeTestAlwaysCount = 0;
tng.run();
Assert.assertEquals(TestBase.beforeTestCount, 1);
Assert.assertEquals(TestBase.beforeTestAlwaysCount, 1);
}
}
代码示例来源:origin: cbeust/testng
@Test
public void testFailingBeforeSuiteShouldSkipAllTests() throws Exception {
TestNG tng = create();
XmlSuite s = createXmlSuite("TESTNG-106");
createXmlTest(s, "myTest1", FailingSuiteFixture.class.getName(), Test1.class.getName());
createXmlTest(s, "myTest2", Test1.class.getName());
createXmlTest(s, "myTest3", Test2.class.getName());
createXmlTest(s, "myTest-last", Test2.class.getName());
tng.setXmlSuites(Arrays.asList(s));
tng.run();
Assert.assertEquals(FailingSuiteFixture.s_invocations, 0, "@BeforeSuite has failed. All tests should be skipped.");
}
}
代码示例来源:origin: cbeust/testng
@Test(description = "GITHUB-435")
public void ensureSuiteLevelPackageIsAppliedToAllTests() throws IOException {
Parser parser = new Parser("src/test/resources/xml/issue435.xml");
List<XmlSuite> suites = parser.parseToList();
XmlSuite xmlsuite = suites.get(0);
assertThat(xmlsuite.getTests().get(0).getClasses().size()).isEqualTo(0);
TestNG testNG = create();
testNG.setXmlSuites(suites);
testNG.setUseDefaultListeners(false);
testNG.run();
assertThat(xmlsuite.getTests().get(0).getClasses().size()).isEqualTo(1);
}
代码示例来源:origin: cbeust/testng
@Test
public void testParallelModeInheritanceInCommandlineMode() throws FileNotFoundException {
SuiteXmlParser parser = new SuiteXmlParser();
String file = "src/test/resources/1636.xml";
XmlSuite xmlSuite = parser.parse(file, new FileInputStream(file), true);
TestNG tng = new TestNG();
tng.setXmlSuites(Collections.singletonList(xmlSuite));
tng.run();
assertThat(Github1636Sample.threads).hasSize(3);
}
代码示例来源:origin: cbeust/testng
private void runTest(XmlSuite suite) {
final XmlTest test = createXmlTest(suite, "Simple Test", TestTestngCounter.class.getName());
suite.setTests(Collections.singletonList(test));
final TestListenerAdapter tla = new TestListenerAdapter();
final TestNG tng = create();
tng.setXmlSuites(Collections.singletonList(suite));
tng.addListener((ITestNGListener) tla);
tng.run();
Assert.assertEquals(tla.getFailedTests().size(), 0);
Assert.assertEquals(tla.getPassedTests().size(), 2);
}
}
代码示例来源:origin: cbeust/testng
public static void main(String[] args) throws Exception {
TestNG tng = new TestNG();
String xml =
"<suite name=\"dgf\" verbose=\"10\">"
+ "<test name=\"dgf\">"
+ "<classes><class name=\"test.dependent.MissingGroupSampleTest\"></class></classes>"
+ "</test>"
+ "</suite>";
System.out.println(xml);
ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes());
tng.setXmlSuites(new Parser(is).parseToList());
tng.run();
}
}
代码示例来源:origin: cbeust/testng
@Test(description = "Fix for https://github.com/cbeust/testng/issues/90")
public void afterClassShouldRun() {
XmlSuite s = createXmlSuite("Bug90");
XmlTest t = createXmlTest(s, "Bug90 test", Sample.class.getName());
XmlClass c = t.getClasses().get(0);
c.setIncludedMethods(Collections.singletonList(new XmlInclude("test1")));
TestNG tng = create();
tng.setXmlSuites(Collections.singletonList(s));
Sample.m_afterClassWasRun = false;
tng.run();
Assert.assertTrue(Sample.m_afterClassWasRun);
}
}
代码示例来源:origin: cbeust/testng
@Test(description = "preserve-order on a factory doesn't cause an NPE")
public void factoryPreserve() {
TestNG tng = create();
XmlSuite suite = createXmlSuite("FactoryPreserve");
XmlTest test = createXmlTest(suite, "Test", ClassSampleFactory.class);
test.setPreserveOrder(true);
tng.setXmlSuites(Arrays.asList(suite));
tng.run();
}
代码示例来源:origin: cbeust/testng
private XmlSuite runTest(Class<?> listenerClass, String listenerName) {
XmlSuite s = createXmlSuite(ALTER_SUITE_LISTENER);
createXmlTest(s, "Test", listenerClass.getName());
boolean addListener = (listenerName != null);
if (addListener) {
s.addListener(listenerName);
}
TestNG tng = create();
tng.setXmlSuites(Arrays.asList(s));
tng.run();
return s;
}
代码示例来源:origin: cbeust/testng
@Test
public void afterClassShouldRun() {
XmlSuite s = createXmlSuite("S");
XmlTest t = createXmlTest(s, "T", Main.class.getName());
XmlClass c = t.getXmlClasses().get(0);
c.getIncludedMethods().add(new XmlInclude("test1"));
t.setPreserveOrder(true);
TestNG tng = create();
tng.setXmlSuites(Arrays.asList(new XmlSuite[] { s }));
Main.m_passed = false;
tng.run();
Assert.assertTrue(Main.m_passed);
}
}
代码示例来源:origin: cbeust/testng
@Test
public void executionListenerAndSuiteListenerTest() {
String suiteFile = getPathToResource("executionlistenersingletoncheck/parent.xml");
List<XmlSuite> suites = getSuites(suiteFile);
TestNG testng = new TestNG();
testng.setXmlSuites(suites);
testng.run();
assertEquals(ExecutionListenerAndSuiteListener.getTmpString(), "INITIALIZED");
}
}
代码示例来源:origin: cbeust/testng
@Test
public void checkXmlSuiteAddition() throws IOException {
TestNG tng = create();
String testngXmlPath = getPathToResource("sanitycheck/test-s-b.xml");
Parser parser = new Parser(testngXmlPath);
tng.setXmlSuites(parser.parseToList());
tng.initializeSuitesAndJarFile();
}
}
代码示例来源:origin: cbeust/testng
@Test
public void testMethod() {
XmlTest xmlTest = createXmlTest("1745_suite", "1745_test", SuiteXmlPoweredFactoryTest.class);
xmlTest.addParameter("number", "3");
TestNG testng = create();
testng.setXmlSuites(Collections.singletonList(xmlTest.getSuite()));
InvokedMethodNameListener listener = new InvokedMethodNameListener();
testng.addListener(listener);
testng.run();
assertThat(listener.getSucceedMethodNames())
.containsExactly(TEST_METHOD, TEST_METHOD, TEST_METHOD, TEST_METHOD);
}
}
代码示例来源:origin: cbeust/testng
@Test(description = "GITHUB-1668")
public void ensureNoExceptionsAreRaisedWhenMethodSelectorsDefinedAtSuiteLevel()
throws IOException {
Parser parser = new Parser("src/test/resources/xml/issue1668.xml");
List<XmlSuite> suites = parser.parseToList();
XmlSuite xmlsuite = suites.get(0);
TestNG testNG = create();
testNG.setXmlSuites(suites);
testNG.setUseDefaultListeners(false);
testNG.run();
// Trigger a call to "toXml()" to ensure that there is no exception raised.
assertThat(xmlsuite.toXml()).isNotEmpty();
}
代码示例来源:origin: cbeust/testng
@Test(dataProvider = "dpMethods")
public void preserveMethodOrder(String[] methods) {
TestNG tng = create();
XmlSuite suite = createXmlSuite("Suite");
XmlTest test = createXmlTest(suite, "Test", A.class);
addMethods(test.getXmlClasses().get(0), methods);
test.setPreserveOrder(true);
tng.setXmlSuites(Arrays.asList(suite));
InvokedMethodNameListener listener = new InvokedMethodNameListener();
tng.addListener((ITestNGListener) listener);
tng.run();
assertThat(listener.getInvokedMethodNames()).containsExactly(methods);
}
代码示例来源:origin: cbeust/testng
@Test
public void orderShouldBePreservedWithDependencies() {
TestNG tng = create();
XmlSuite suite = createXmlSuite("PreserveOrder");
XmlTest test = createXmlTest(suite, "Test", Chuck4Sample.class, Chuck3Sample.class);
test.setPreserveOrder(true);
tng.setXmlSuites(Arrays.asList(suite));
InvokedMethodNameListener listener = new InvokedMethodNameListener();
tng.addListener((ITestNGListener) listener);
tng.run();
assertThat(listener.getSucceedMethodNames()).containsExactly(
"c4TestOne", "c4TestTwo", "c4TestThree",
"c3TestOne", "c3TestTwo", "c3TestThree"
);
}
代码示例来源:origin: cbeust/testng
private void runTest(String group, String excludedGroups, List<String> methods) {
XmlSuite s = createXmlSuite(getClass().getName());
createXmlTest(s, "Test", OverrideSampleTest.class.getName());
TestNG tng = create();
if (group != null) tng.setGroups(group);
if (excludedGroups != null) tng.setExcludedGroups(excludedGroups);
tng.setXmlSuites(Collections.singletonList(s));
TestListenerAdapter tla = new TestListenerAdapter();
tng.addListener(tla);
tng.run();
assertTestResultsEqual(tla.getPassedTests(), methods);
}
内容来源于网络,如有侵权,请联系作者删除!