Greg,
I didn’t quite get as to what you are trying to achieve.
Being able to control the data provider thread count is a pretty straight forward thing that you can do with TestNG.
For doing it you would be leveraging org.testng.IAlterSuiteListener
Here’s a sample that shows how to do this:
A sample listener could look like below:
import org.testng.IAlterSuiteListener;
import org.testng.xml.XmlSuite;
import java.util.List;
public class SuiteAlterer implements IAlterSuiteListener {
@Override
public void alter(List<XmlSuite> suites) {
int count = Integer.parseInt(System.getProperty("threadcount", "3"));
XmlSuite suite = suites.get(0);
suite.setDataProviderThreadCount(count);
}
}
Here’s a test class:
import org.testng.TestNG;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class TestClassSample {
public static void main(String[] args) {
System.setProperty("threadcount", "20");
TestNG testng = new TestNG();
testng.setTestClasses(new Class<?>[]{TestClassSample.class});
testng.addListener(new SuiteAlterer());
testng.run();
}
@Test(dataProvider = "dp")
public void testMethod(int i) {
System.err.println("Running with the value (" + i + ") on thread [" + Thread.currentThread().getId() + "]");
}
@DataProvider(name = "dp", parallel = true)
public Object[][] getData() {
int size = 20;
Object[][] objects = new Object[size][1];
for (int i = 0; i < size; i++) {
objects[i] = new Object[]{i};
}
return objects;
}
}
Here’s the output:
Running with the value (18) on thread [29]
Running with the value (0) on thread [11]
Running with the value (2) on thread [13]
Running with the value (16) on thread [27]
Running with the value (10) on thread [21]
Running with the value (15) on thread [26]
Running with the value (3) on thread [14]
Running with the value (7) on thread [18]
Running with the value (19) on thread [30]
Running with the value (8) on thread [19]
Running with the value (9) on thread [20]
Running with the value (17) on thread [28]
Running with the value (5) on thread [16]
Running with the value (11) on thread [22]
Running with the value (14) on thread [25]
Running with the value (4) on thread [15]
Running with the value (6) on thread [17]
Running with the value (12) on thread [23]
Running with the value (1) on thread [12]
Running with the value (13) on thread [24]
===============================================
Command line suite
Total tests run: 20, Failures: 0, Skips: 0
===============================================
Process finished with exit code 0
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/UW1Ydj0_wMc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to testng-users+unsubscribe@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.