使用DataProvider进行TestNG并行执行 [英] TestNG parallel Execution with DataProvider

查看:186
本文介绍了使用DataProvider进行TestNG并行执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个测试从数据提供者接收数据。我希望这个测试与数据提供者的不同值并行运行。

I have a single test which receives data from data provider. I would like this test to run in parallel with different values from data provider .

我尝试过这样的方法:

public class IndependentTest
{
@Test(dataProvider = "dp1" ,threadPoolSize=3,invocationCount=1)

public void testMethod(int number)
{
    Long id = Thread.currentThread().getId();
    System.out.println("HELLO :  " + id);
}


@DataProvider(name = "dp1",parallel=true)
public Object[][] dp1() {
  return new Object[][] {
      new Object[] { 1 },
      new Object[] { 2 },
      new Object[] { 3 },
      new Object[] { 4 },
      new Object[] { 5 },
      new Object[] { 6 },
      new Object[] { 7 },
      new Object[] { 8 }

  };
}

}

我收到的输出是:

HELLO:10

HELLO:12

你好:17

你好:11

HELLO:16

HELLO:14

HELLO:13

HELLO:15

当我在线程池大小中指定5时,产生了10个线程。
您能告诉我们要在上面的代码段中添加什么来控制数据提供程序线程池大小。

Spawned 10 threads while i specified 5 in the thread pool size . Could you please tell what has to be added to the above snippet to control the data provider thread pool size .

推荐答案

您需要使用dataproviderthreadcount。不需要threadpoolsize和invocationcount。

You need to use dataproviderthreadcount. threadpoolsize and invocationcount are not required.

这篇关于使用DataProvider进行TestNG并行执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆