ThreadPoolSize


The attribute will be invoked from multiple threads as specified by invocationCount.

Note: this attribute is ignored if invocationCount is not specified

Lets create java class
import org.testng.annotations.Test;
publicclassthreadpoolsizeexample {
@Test(invocationCount = 10,threadPoolSize=3 )
publicvoid testMethod1() {
System.out.println("This is testMethod1");
}
@Test
publicvoid testMethod2() {
System.out.println("This is testMethod2");
}
}

TestNG.xml

<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEsuiteSYSTEM"http://testng.org/testng-1.0.dtd">
<suitename="Suite"parallel="none">
<testname="Test1">
<classes>
<classname="threadpoolsizeexample"/>
</classes>
</test><!-- Test -->
</suite><!-- Suite -->

Results

image

Here, testMethod1 is executed 10 times via multiple thread pool. it will decrease the running time of the test method.

Comments