suite parallel set to classes not work in 6.14.3
TestNG Version
Note: only the latest version is supported
Expected behavior
classes should start at the same time and run in different threads
Actual behavior
classes run one after another finished.
Is the issue reproductible on runner?
- [ ] Shell
- [ ] Maven
- [ ] Gradle
- [ ] Ant
- [ ] Eclipse
- [ ] IntelliJ
- [ ] NetBeans
Test case sample
Please, share the test case (as small as possible) which shows the issue testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="ClassParallelTest" parallel="classes" thread-count="3">
<test verbose="2" name="action" group-by-instances="true">
<classes>
<class name="SeTest"/>
<class name="PeTest"/>
</classes>
</test>
</suite>
classes: class 1st:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.*;
/**
* 类说明
*
* @author Pis
* @version $Id: PeTest.java, v0.1 2017/6/28.17:19 Exp $
*/
public class PeTest {
private WebDriver driver;
@BeforeClass
public void getDriverInstance(){
System.out.println("Current Thread Id: " + Thread.currentThread().getId());
//设置驱动所在位置
System.setProperty("webdriver.chrome.driver", "/Users/pis/Downloads/chromedriver");
driver = new ChromeDriver();
}
@AfterClass
public void afterClass(){
//关闭浏览器进程及驱动
driver.quit();
}
@Test
public void actionP1() {
driver.get("http://www.baidu.com");
try {
//页面等待
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Test
public void actionsP2() {
driver.get("http://www.sina.com");
try {
//页面等待
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
class 2nd:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.*;
/**
* 类说明
*
* @author Pis
* @version $Id: SeTest.java, v0.1 2017/6/28.17:19 Exp $
*/
public class SeTest {
private WebDriver driver;
@BeforeClass
public void getDriverInstance(){
System.out.println("Current Thread Id: " + Thread.currentThread().getId());
//设置驱动所在位置
System.setProperty("webdriver.chrome.driver", "/Users/pis/Downloads/chromedriver");
driver = new ChromeDriver();
}
@AfterClass
public void afterClass(){
//关闭浏览器进程及驱动
driver.quit();
}
@Test
public void actionS1() {
driver.get("http://www.baidu.com");
try {
//页面等待
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Test
public void actionsS2() {
driver.get("http://www.sina.com");
try {
//页面等待
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

I am also facing this issue . I just updated testng version from 6.11 to 6.14.3 & found that tests are not running in parallel (when having parallel='tests' & thread-count set in suite.xml)
My Suite.xml is as follows
<suite name="mysuite" verbose="1" parallel="tests" thread-count="5">
<test name="misc.LoginTest1">
<classes>
<class name="com.test.misc.LoginTest1" />
</classes>
</test>
<test name="misc.LoginTest2">
<classes>
<class name="com.test.misc.LoginTest2" />
</classes>
</test>
<test name="misc.LoginTest3">
<classes>
<class name="com.test.misc.LoginTest3" />
</classes>
</test>
<test name="misc.LoginTest4">
<classes>
<class name="com.test.misc.LoginTest4" />
</classes>
</test>
<test name="misc.LoginTest5">
<classes>
<class name="com.test.misc.LoginTest5" />
</classes>
</test>
</suite>
@RealLau
I can no longer reproduce this issue using the latest released version of TestNG viz. 7.0.0-beta1. Here's a sample that I used (Its the same as yours but just removed all the selenium code to keep it simple)
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class SeTest {
@BeforeClass
public void getDriverInstance() {
System.out.println("Current Thread Id: " + Thread.currentThread().getId());
}
@AfterClass
public void afterClass() {}
@Test
public void actionS1() {
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Test
public void actionsS2() {
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class PeTest {
@BeforeClass
public void getDriverInstance(){
System.out.println("Current Thread Id: " + Thread.currentThread().getId());
}
@AfterClass
public void afterClass(){
}
@Test
public void actionP1() {
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Test
public void actionsP2() {
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
TestNG suite xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="ClassParallelTest" parallel="classes" thread-count="3">
<test verbose="2" name="action" group-by-instances="true">
<classes>
<class name="com.rationaleemotions.github.issue1898.SeTest"/>
<class name="com.rationaleemotions.github.issue1898.PeTest"/>
</classes>
</test>
</suite>
Output
Current Thread Id: 11
Current Thread Id: 12
PASSED: actionS1
PASSED: actionsS2
PASSED: actionP1
PASSED: actionsP2
===============================================
action
Tests run: 4, Failures: 0, Skips: 0
===============================================
===============================================
ClassParallelTest
Total tests run: 4, Passes: 4, Failures: 0, Skips: 0
===============================================
Process finished with exit code 0
@sjethvani - This is no longer an issue using latest released version of TestNG 7.0.0-beta1.
For the same sample class, here's a modified version of the suite xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="ClassParallelTest" parallel="tests" thread-count="3">
<test verbose="2" name="action1" group-by-instances="true">
<classes>
<class name="com.rationaleemotions.github.issue1898.SeTest"/>
</classes>
</test>
<test verbose="2" name="action2" group-by-instances="true">
<classes>
<class name="com.rationaleemotions.github.issue1898.PeTest"/>
</classes>
</test>
</suite>
and the output is as below
Current Thread Id: 11
Current Thread Id: 12
PASSED: actionS1
PASSED: actionP1
PASSED: actionsS2
PASSED: actionsP2
===============================================
action2
Tests run: 2, Failures: 0, Skips: 0
===============================================
===============================================
action1
Tests run: 2, Failures: 0, Skips: 0
===============================================
===============================================
ClassParallelTest
Total tests run: 4, Passes: 4, Failures: 0, Skips: 0
===============================================
Process finished with exit code 0
Am closing this issue, since its no longer a problem. In case this is still a problem using the latest released version of TestNG (7.0.0-beta1) please comment with a simple standalone example.
@RealLau - On a side note, just curious. How did you create that gif for the execution output ? It looks very nice. Can you please share info on how to do that on OSX ?
@krmahadevan I know this was marked as closed, but I'm also having a similar issue, even when I updated to 7.0.0-beta1. I have multiple
I only get like 3 browsers/threads being used, which is odd. Any idea why this would be? It's baffling.
@Proryanator - Hard to say. Please help share a sample that can be used to reproduce the problem.
It was actually a misundertanding on my part on how it worked. In a suite file with parallel="classes" in the
To run more
I am facing issue still with 7.0.0 beta 1. below is the test suite..
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel = "tests" thread-count="2">
<test name="Test1">
<classes>
<class name="RegressionTests.TestScripts"/>
</classes>
</test> <!-- Test -->
<test name="Test2">
<classes>
<class name="RegressionTests.TestScripts3"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
@gangadharmd - Merely sharing the xml doesn't help a lot. Please help create a simple standalone project (without any other dependencies of-course) which can be used to reproduce the problem along with what you expect as output and what actually is the output.
Also please dont forget to try this out on the latest released version viz., 7.0.0-beta3