Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

java - TestNG parallel Execution with DataProvider

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 .

I tried an approach like :

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 }

  };
}

}

The output i received is :

HELLO : 10

HELLO : 12

HELLO : 17

HELLO : 11

HELLO : 16

HELLO : 14

HELLO : 13

HELLO : 15

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 .

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to use dataproviderthreadcount. The threadpoolsize and invocationcount values are not required. See details here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...