New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testng executes the @BeforeClass and every @Test at a different thread #1333
Comments
Duplicate of #1185 Feel free to reopen if you think it is a different issue. |
Comment from #1335 by @yardening2
@yardening2 Ok. Do you think it is a duplicate of #1035 in that case? |
@juherr In other words, every @test creates a new thread id. This happend to me only after updating my TestNG version from 6.9.10 to 6.10. I think when in the testng.xml I specify parallel="tests" not every @test should create a new thread. |
@juherr Review this example: public class Test{
@BeforeClass
public void init(){
System.out.println(Thread.currentThread().getId());
}
@Test
public void test1(){
System.out.println(Thread.currentThread().getId());
}
@Test
public void test2(){
System.out.println(Thread.currentThread().getId());
}
} <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="D1 Tests" verbose="0" parallel="tests" thread-count="10" time-out="7200000">
<test name="test1">
<classes>
<class name="Test"></class>
</classes>
</test>
<test name="test2">
<classes>
<class name="Test"></class>
</classes>
</test>
<test name="test3">
<classes>
<class name="Test"></class>
</classes>
</test>
</suite> I get a different thread id for every method although each tag should be 1 thread. The reason is the Very strange behavior. Any idea why this happens? |
@yardening2 Sure! The timeout feature is done by a thread pool on its own threads. I'm pretty sure you issue, or a similar one, is already registered: https://github.com/cbeust/testng/issues?q=is%3Aopen+is%3Aissue+label%3A%22Feature%3A+timeout%22 |
Hi, In my case, the @BeforeClass method is executed before every test in the class. The testNG xml file looks like below. I am trying testing on one device for now - but plan is to test on multiple devices at the same time.
|
@juherr there will be a fix for this bug soon ? |
@selenUser - Does your scenario involve timeouts ? If not, then please try reproducing this issue using TestNG |
as well as @BedoreMethod and @AfterMethod |
TestNG Version
6.10
Expected behavior
The whole
<test>name</test>
should run on one threadActual behavior
each @test inside the class is executed on a different thread
Is the issue reproductible on runner?
Test case sample
So this is the test class. 1
@BeforeClass
and 2@Test
:This is the xml with 3
<test>
each with the previous class:This is the log i created with the created threads in every
@Test
.As you can see there are more threads created than expected by this example:
The text was updated successfully, but these errors were encountered: