DependsOnMethods made parallel class use several threads
See original GitHub issueTestNG Version
6.9.12 and 6.9.13.8
Expected behavior
When setting TestNG to run tests in parallel by class, all the tests in a single class should be run in the same thread.
Actual behavior
If one of the test method depends on another, a new thread is created, which is really annoying for Selenium case for instance (BeforeClass open the browser, AfterClass kill it)
Test case sample
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="main" parallel="classes" thread-count="2" verbose="0" group-by-instances="false">
<test name="all">
<classes>
<class name="TestFoo"/>
</classes>
</test>
</suite>
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class TestFoo {
@BeforeClass
public void navigateTo() {
System.out.print("BeforeClass - ");
printThread();
}
private void printThread() {
System.out.println(Thread.currentThread().getName());
}
@AfterClass
public void die() {
System.out.print("AfterClass - ");
printThread();
}
@Test
public void t1() {
System.out.print("T1 - ");
printThread();
}
@Test(dependsOnMethods = "t1")
public void t2() {
System.out.print("T2 - ");
printThread();
}
}
BeforeClass - pool-1-thread-1
T1 - pool-1-thread-1
T2 - pool-1-thread-2
AfterClass - pool-1-thread-2
What I’ve tried:
- singleThreaded = true
- group-by-instance=“true”
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:38 (2 by maintainers)
Top Results From Across the Web
TestNG parallel="classes" and dependsOnMethods
This is open TestNG issue https://github.com/cbeust/testng/issues/1185 parallel="classes" and dependsOnMethods does not work together as ...
Read more >parallel="methods" + dependsOnMethods() - Google Groups
After C got finished, D runs in the same Thread as C. I hoped, that testNG will use as many Threads as possible,...
Read more >DependsOnMethods made parallel class use several threads -
When setting TestNG to run tests in parallel by class, all the tests in a single class should be run in the same...
Read more >Parallel Execution in Selenium: Session Handling & TestNG ...
A new sessionID is created for a new instance of WebDriver. · One session will bind with one particular browser. · Using attribute...
Read more >Documentation - TestNG
If not set, default mechanism is not to use parallel threads at all. ... The example will make TestNG create two test classes,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, the problem is located in GraphThreadPoolExecutor/DynamicGraph. But I don’t know how to fix it for the moment. Don’t expect a quick fix, sorry.
I have come across an issue. When i tried this (on both beta7 and beta1) with the VM argument -Dtestng.thread.affinity=true :
and then tried to run through xml like this :
I got an exception :
This exception is thrown when there is more then one test with no dependOnMethods