本文整理了Java中org.testng.TestNG.setParallel()
方法的一些代码示例,展示了TestNG.setParallel()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestNG.setParallel()
方法的具体详情如下:
包路径:org.testng.TestNG
类名称:TestNG
方法名:setParallel
[英]Define whether this run will be run in parallel mode.
[中]定义此运行是否将以并行模式运行。
代码示例来源:origin: org.testng/testng
/**
* Define whether this run will be run in parallel mode.
* @deprecated Use #setParallel(XmlSuite.ParallelMode) instead
*/
@Deprecated
public void setParallel(String parallel) {
if (parallel == null) {
setParallel(XmlSuite.ParallelMode.NONE);
} else {
setParallel(XmlSuite.ParallelMode.getValidParallel(parallel));
}
}
代码示例来源:origin: cbeust/testng
/**
* Define whether this run will be run in parallel mode.
*
* @deprecated Use #setParallel(XmlSuite.ParallelMode) instead
*/
@Deprecated
// TODO: krmahadevan: This method is being used by Gradle. Removal causes build failures.
public void setParallel(String parallel) {
if (parallel == null) {
setParallel(XmlSuite.ParallelMode.NONE);
} else {
setParallel(XmlSuite.ParallelMode.getValidParallel(parallel));
}
}
代码示例来源:origin: cbeust/testng
@Test(timeOut = 1000)
public void shouldNotLockUpWithInterceptorThatRemovesMethods() {
TestNG tng = create(LockUpInterceptorSampleTest.class);
tng.setParallel(XmlSuite.ParallelMode.METHODS);
tng.run();
}
}
代码示例来源:origin: cbeust/testng
@Test
public void beforeClassMethodsShouldRunInParallel() {
TestNG tng = create(BeforeClassThreadA.class, BeforeClassThreadB.class);
tng.setParallel(XmlSuite.ParallelMode.METHODS);
tng.run();
assertThat(Math.abs(BeforeClassThreadA.WHEN - BeforeClassThreadB.WHEN)).isLessThan(1000);
}
}
代码示例来源:origin: cbeust/testng
@Test(dataProvider = "dp")
public void testMethod(Class<?> clazz) {
TestNG testNG = create(clazz);
testNG.setParallel(XmlSuite.ParallelMode.METHODS);
testNG.run();
assertThat(testNG.getStatus()).isEqualTo(0);
}
代码示例来源:origin: cbeust/testng
@Test
public void ensureThatParallelismAndThreadCountAreRallied() {
TestNG testng = create();
testng.setTestSuites(Collections.singletonList("src/test/resources/987.xml"));
testng.setThreadCount(2);
testng.setParallel(XmlSuite.ParallelMode.METHODS);
testng.run();
assertThat(Issue987TestSample.maps).hasSize(2);
assertThat(Issue987TestSample.maps.values()).contains("method2", "method1");
}
代码示例来源:origin: cbeust/testng
@Test(description = "https://github.com/cbeust/testng/issues/811")
public void testTimeOutWhenParallelIsTest() {
TestNG tng = create(TimeOutWithParallelSample.class);
tng.setParallel(XmlSuite.ParallelMode.TESTS);
InvokedMethodNameListener listener = new InvokedMethodNameListener();
tng.addListener((ITestNGListener) listener);
tng.run();
assertThat(listener.getFailedMethodNames()).containsExactly("myTestMethod");
assertThat(listener.getSkippedMethodNames()).isEmpty();
assertThat(listener.getSucceedMethodNames()).isEmpty();
}
代码示例来源:origin: cbeust/testng
@Test(description = "GITHUB #1334: Order by priority gets messed up when there are failures and dependsOnMethods")
public void priorityWithDependencyAndFailures() {
TestNG tng = create(SampleTest01.class, SampleTest02.class);
tng.setParallel(XmlSuite.ParallelMode.CLASSES);
InvokedMethodNameListener listener = new InvokedMethodNameListener();
tng.addListener(listener);
tng.run();
List<String> expected = Arrays.asList("test0010_createAction", "test0030_advancedSearch",
"test0060_deleteAction");
List<String> allSkipped = listener.getSkippedMethodNames();
//Remove skipped methods from SampleTest01's invoked methods.
List<String> actual = listener.getMethodsForTestClass(SampleTest01.class)
.stream()
.filter(each -> !allSkipped.contains(each))
.collect(Collectors.toList());
assertThat(actual).containsExactlyElementsOf(expected);
}
代码示例来源:origin: cbeust/testng
private void test(int threadCount) {
Helper.reset();
MultiThreadedDependentSampleTest.m_methods = Lists.newArrayList();
TestNG tng = create(MultiThreadedDependentSampleTest.class);
tng.setThreadCount(threadCount);
tng.setParallel(XmlSuite.ParallelMode.METHODS);
Map<Long, Long> map = Helper.getMap(MultiThreadedDependentSampleTest.class.getName());
synchronized(map) {
tng.run();
Assert.assertTrue(map.size() > 1, "Map size:" + map.size() + " expected more than 1");
assertOrder(MultiThreadedDependentSampleTest.m_methods);
}
}
}
代码示例来源:origin: cbeust/testng
@Test(dataProvider = "dp1380", description = "GITHUB-1380")
public void simpleCyclingDependencyShouldWork(
Class<?> testClass, String[] runMethods, boolean isParallel) {
TestNG tng = SimpleBaseTest.create(testClass);
if (isParallel) {
tng.setParallel(ParallelMode.METHODS);
}
InvokedMethodNameListener listener = new InvokedMethodNameListener();
tng.addListener(listener);
tng.run();
if (!isParallel) {
// When not running parallel, invoke order and succeed order are the same.
assertThat(listener.getInvokedMethodNames()).containsExactly(runMethods);
assertThat(listener.getSucceedMethodNames()).containsExactly(runMethods);
} else {
// When running parallel, invoke order is consistent, but succeed order isn't.
assertThat(listener.getInvokedMethodNames()).containsExactly(runMethods);
assertThat(listener.getSucceedMethodNames()).containsExactlyInAnyOrder(runMethods);
}
}
}
代码示例来源:origin: cbeust/testng
private void assertIssue87(Class<?>... tests) {
TestNG tng = create(tests);
tng.setParallel(XmlSuite.ParallelMode.NONE);
tng.setPreserveOrder(true);
InvokedMethodListener listener = new InvokedMethodListener();
tng.addListener((ITestNGListener) listener);
tng.run();
List<IInvokedMethod> m = listener.getInvokedMethods();
Assert.assertEquals(m.get(0).getTestMethod().getMethodName(), "someMethod1");
Assert.assertEquals(m.get(1).getTestMethod().getMethodName(), "someMethod3");
Assert.assertEquals(m.get(2).getTestMethod().getMethodName(), "someTest");
Assert.assertEquals(m.size(), 3);
}
}
代码示例来源:origin: cbeust/testng
private void runTest(XmlSuite.ParallelMode parallelMode, int expectedThreadIdCount) {
TestNG tng = new TestNG();
tng.setVerbose(0);
tng.setTestClasses(new Class[] { FactorySampleTest.class});
if (parallelMode != null) {
tng.setParallel(parallelMode);
}
TestListenerAdapter tla = new TestListenerAdapter();
tng.addListener((ITestNGListener) tla);
B.setUp();
tng.run();
Assert.assertEquals(tla.getPassedTests().size(), 2);
Assert.assertEquals(B.m_threadIds.size(), expectedThreadIdCount);
}
代码示例来源:origin: cbeust/testng
private void runTest(Class<?> cls, boolean parallel, String... methods) {
TestNG tng = create(cls);
InvokedMethodNameListener listener = new InvokedMethodNameListener();
tng.addListener(listener);
if (parallel) {
tng.setParallel(XmlSuite.ParallelMode.METHODS);
}
tng.run();
if (parallel) {
//If tests are being executed in parallel, then order of methods is non-deterministic.
assertThat(listener.getInvokedMethodNames()).containsExactlyInAnyOrder(methods);
} else {
assertThat(listener.getInvokedMethodNames()).containsExactly(methods);
}
}
代码示例来源:origin: cbeust/testng
@Test(invocationCount = 500)
public void testInvocationCounterIsCorrectForMethodWithDataProvider() {
final TestNG tng = create(FailedDPTest.class);
tng.setThreadCount(1);
tng.setParallel(XmlSuite.ParallelMode.NONE);
tng.setPreserveOrder(true);
final TestListenerAdapter tla = new TestListenerAdapter();
tng.addListener((ITestNGListener) tla);
tng.run();
ITestNGMethod method = tla.getTestContexts().get(0).getAllTestMethods()[0];
List<Integer> failed = method.getFailedInvocationNumbers();
assertEqualsNoOrder(failed.toArray(), FailedDPTest.primes.toArray());
}
}
代码示例来源:origin: org.testng/testng
setSkipFailedInvocationCounts(cla.skipFailedInvocationCounts);
if (cla.parallelMode != null) {
setParallel(cla.parallelMode);
代码示例来源:origin: cbeust/testng
setSkipFailedInvocationCounts(cla.skipFailedInvocationCounts);
if (cla.parallelMode != null) {
setParallel(cla.parallelMode);
代码示例来源:origin: cbeust/testng
tng.setParallel(XmlSuite.ParallelMode.INSTANCES);
tng.setPreserveOrder(false);
代码示例来源:origin: stackoverflow.com
public class TestRunner
{
public static void main(String[] args)
{
TestNG testng = new TestNG();
TestListenerAdapter adapter = new TestListenerAdapter();
List<String> suites = new ArrayList<String>();
testng.addListener(adapter);
suites.add(args[0]);
testng.setTestSuites(suites);
testng.setParallel("parallel");
testng.setSuiteThreadPoolSize(5);
testng.setOutputDirectory("path to output");
testng.run();
}
}
内容来源于网络,如有侵权,请联系作者删除!