Hi,
I am using testng-5.12.1 and the <suite parallel="classes"> seems to
not be working in parallel mode.
I have a single test class with several @Test annotations. I have also
a class-level @Tes(sequential=true) annotation because I need the
methods inside the class to be run consequitively in a single thread.
I want to run multiple parallel threads of this class, so I have
created a wrapper @Factory class which returns an array of my test
classes.
public class ThreadGenerator {
@Parameters({"counter"})
@Factory
public Object[] generateTests(int count) {
Object[] tests = new Object[count];
for (int i=0; i < count; i++) {
LoginTest test = new LoginTest(i);
tests[i] = test;
}
return tests;
}
}
The test itself looks like this:
public class LoginTest {
private HttpClient client;
public LoginTest(int count) {
super();
id_count = count;
}
@BeforeClass
public void setUp() {
client = new AMFClient(getConnectionManager());
client.doSSLLogin("
http://localhost", "user" + id_count,
"pass");
}
private synchronized MultiThreadedHttpConnectionManager
getConnectionManager() {
if (null == conmanager) {
MultiThreadedHttpConnectionManager conmanager = new
MultiThreadedHttpConnectionManager();
}
return conmanager;
}
@AfterClass
public void cleanUp() {
client.closeConnection();
}
@Test(groups={"amftest"}, alwaysRun=true)
private void sendPostRequest1() {
client.doWork1();
}
@Test(groups={"amftest"}, alwaysRun=true)
private void sendPostRequest2() {
client.doWork2();
}
}
My testng.xml file looks like this:
<suite parallel="classes" thread-count="20" time-out="10000">
<test>
<classes>
<class name="ThreadGenerator" />
</classes>
</test>
</suite>
The tests run single-threaded despite `parallel="classes"` at the
suite-level.
I have also tried to use @Test(sequential=true, threadPoolSize = 20,
invocationCount = 20, timeOut = 1000000000) as the class-level
annotation for LoginTest but it does not have any effect.
Where did I go wrong?
Any help or pointers will be appreciated.
Best,
cp