本文整理了Java中org.testng.TestNG.setGroups()
方法的一些代码示例,展示了TestNG.setGroups()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestNG.setGroups()
方法的具体详情如下:
包路径:org.testng.TestNG
类名称:TestNG
方法名:setGroups
[英]Define which groups will be included from this run.
[中]定义此运行将包括哪些组。
代码示例来源:origin: cbeust/testng
@Test
public void shouldNotUseThreadsIfNotUsingParallel() {
TestNG tng = create(DataProviderThreadPoolSizeSampleTest.class);
tng.setGroups("sequential");
tng.run();
Assert.assertEquals(DataProviderThreadPoolSizeSampleTest.getThreadCount(), 1);
}
代码示例来源:origin: cbeust/testng
@Test
public void shouldUseDefaultDataProviderThreadCount() {
TestNG tng = create(DataProviderThreadPoolSizeSampleTest.class);
tng.setGroups("parallel");
tng.run();
Assert.assertEquals(DataProviderThreadPoolSizeSampleTest.getThreadCount(), 10);
}
代码示例来源:origin: cbeust/testng
@Test
public void shouldUseSpecifiedDataProviderThreadCount() {
TestNG tng = create(DataProviderThreadPoolSizeSampleTest.class);
tng.setGroups("parallel");
tng.setDataProviderThreadCount(3);
tng.run();
Assert.assertEquals(DataProviderThreadPoolSizeSampleTest.getThreadCount(), 3);
}
}
代码示例来源:origin: cbeust/testng
@Test(dataProvider = "getTestData")
public void testBeforeSuiteInjection(Class clazz, String methodName, String expected) {
TestNG tng = create(clazz);
InjectionResultHolder holder = new InjectionResultHolder();
tng.addListener(holder);
tng.setGroups("test");
tng.run();
Assert.assertTrue(holder.getErrorMessage().contains(expected + methodName));
}
代码示例来源:origin: cbeust/testng
@Test(dataProvider = "dp")
public void verify(int number, String passed) {
TestNG tng = create(TestContextSample.class);
tng.setGroups(String.valueOf(number));
InvokedMethodNameListener listener = new InvokedMethodNameListener();
tng.addListener(listener);
tng.run();
assertThat(listener.getSucceedMethodNames()).hasSize(1);
assertThat(listener.getSucceedMethodNames().get(0))
.matches(passed + "\\(\\[foo(,foo){" + (number - 1) + "}?\\]\\)");
assertThat(listener.getFailedMethodNames()).isEmpty();
}
}
代码示例来源:origin: cbeust/testng
@Test(description = "First test method")
public void verifyIncludedExcludedCount1() {
m_tng.setTestClasses(new Class[] {IncludedExcludedSampleTest.class});
m_tng.setGroups("a");
m_tng.addListener((ITestNGListener)
new MyReporter(new String[] { "test3" }, new String[] { "test1", "test2"}));
m_tng.run();
}
代码示例来源: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);
}
代码示例来源:origin: cbeust/testng
private void runTest(String include, String exclude) {
File f = Utils.createTempFile(
"<suite name=\"S\">"
+ " <test name=\"T\">"
+ " <classes>"
+ " <class name=\"test.override.OverrideSampleTest\" />"
+ " </classes>"
+ " </test>"
+ "</suite>"
);
TestNG tng = create();
TestListenerAdapter tla = new TestListenerAdapter();
tng.addListener((ITestNGListener) tla);
if (include != null) tng.setGroups(include);
if (exclude != null) tng.setExcludedGroups(exclude);
tng.setTestSuites(Collections.singletonList(f.getAbsolutePath()));
tng.run();
Assert.assertEquals(tla.getPassedTests().size(), 1);
}
代码示例来源:origin: cbeust/testng
@Test
public void withoutAlwaysRunBefore() {
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = create();
testng.setOutputDirectory(OutputDirectoryPatch.getOutputDirectory());
testng.setTestClasses(new Class[] {AlwaysRunBefore1.class});
testng.setGroups("A");
testng.addListener(tla);
testng.run();
assertTrue(AlwaysRunBefore1.success(), "before alwaysRun methods should have been run");
}
}
代码示例来源:origin: org.testng/testng
setGroups(cla.groups);
setExcludedGroups(cla.excludedGroups);
setTestJar(cla.testJar);
代码示例来源:origin: cbeust/testng
suite.setExcludedGroups(excludedSuiteGroups);
} else {
tng.setGroups(Joiner.on(',').join(suiteGroups));
tng.setExcludedGroups(Joiner.on(',').join(excludedSuiteGroups));
代码示例来源:origin: cbeust/testng
setGroups(cla.groups);
setExcludedGroups(cla.excludedGroups);
setTestJar(cla.testJar);
代码示例来源:origin: infinitest/infinitest
private void applyConfig(TestNG core, TestNGConfiguration config) {
core.setExcludedGroups(config.getExcludedGroups());
core.setGroups(config.getGroups());
if (config.getListeners() != null) {
for (Object listener : config.getListeners()) {
core.addListener(listener);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!