Note- Use threadPoolSize and invocationCount attribute.
The threadPoolSize attribute tells TestNG to create a thread pool to run the test method via multiple threads. With thread pool, it will greatly decrease the running time of the test method.
Ex- Start a thread pool, which contains 4 threads, and run the test method 12 times.
import org.testng.annotations.Test;
public class PerformanceTesting {
@Test(invocationCount=12, threadPoolSize=4)
public void runTest(){
System.out.println("Thread Id: "+Thread.currentThread().getId());
}
}
The threadPoolSize attribute tells TestNG to create a thread pool to run the test method via multiple threads. With thread pool, it will greatly decrease the running time of the test method.
Ex- Start a thread pool, which contains 4 threads, and run the test method 12 times.
import org.testng.annotations.Test;
public class PerformanceTesting {
@Test(invocationCount=12, threadPoolSize=4)
public void runTest(){
System.out.println("Thread Id: "+Thread.currentThread().getId());
}
}