time-out attribute is causing @BeforeMethod and @Test to be run in different threads

39 views
Skip to first unread message

zoomout

unread,
Jan 2, 2017, 11:58:51 AM1/2/17
to testng-users
Setting time-out attribute is causing @BeforeMetod and @Test methods to be executed in different threads. If you remove this attribute, then they are executed in same thread (which is expected behavior).

To reproduce it it one can setup the tests same way as described in this article:

with only one difference (time-out):

<suite name="Test-method Suite" time-out="123456789" parallel="methods" thread-count="2" >

It is crucial to have possibility to run @BeforeMethod and @Test in same thread because it's the only way one can use ThreadLocal to share data between @BeforeMethod and @Test.

Shawn McCarthy

unread,
Jan 2, 2017, 1:10:07 PM1/2/17
to testng-users
Try using InheritableThreadLocal .

Julien Herr

unread,
Jan 2, 2017, 3:27:13 PM1/2/17
to testng-users
Could be related to https://github.com/cbeust/testng/issues/914
Timeout use a theadpool aka another new thread. 
Reply all
Reply to author
Forward
0 new messages