TestNG with parallel = classes behavior inconsistent with documentation

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

TestNG with parallel = classes behavior inconsistent with documentation

Tai Thach
I have a suite defined with parallel="classes" and thread-count="2". Based on the documentation:
  • parallel="classes": TestNG will run all the methods in the same class in the same thread, but each class will be run in a separate thread.
I expect that all methods in the same class (setup and test methods) will run in the same thread. However, based on what I see in my log, it appears that the setup method is executing in thread-1 and my test method is executing in thread-2, even though they are both in the same class. What is the correct behavior? Is the documentation wrong?

I'm running with TestNG version 6.12. 
Thanks,
Tai



--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: TestNG with parallel = classes behavior inconsistent with documentation

Krishnan Mahadevan

I don’t think the setup methods adhere to that rule. The setup methods are first executed and then some of the test methods may or may not run on that same thread. This is to the best of my understanding.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Tai Thach <[hidden email]>
Reply-To: <[hidden email]>
Date: Monday, January 22, 2018 at 5:20 AM
To: testng-users <[hidden email]>
Subject: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

I have a suite defined with parallel="classes" and thread-count="2". Based on the documentation:

  • parallel="classes": TestNG will run all the methods in the same class in the same thread, but each class will be run in a separate thread.

I expect that all methods in the same class (setup and test methods) will run in the same thread. However, based on what I see in my log, it appears that the setup method is executing in thread-1 and my test method is executing in thread-2, even though they are both in the same class. What is the correct behavior? Is the documentation wrong?

 

I'm running with TestNG version 6.12. 

Thanks,

Tai

 

 

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: TestNG with parallel = classes behavior inconsistent with documentation

Tai Thach
Thanks, Krishnan for the clarification.

Do you know if there are any plans to change this? The reason for this is because I do have a use case where I want to use the setup method(s) to initialize data that is only available to that thread (lets call it thread-1). So if the test method executes in another thread (lets call it thread-2), it cannot find the data that I've initialized in thread-1. 

IMHO, with parallel="classes", having all methods of the same class run in the same thread seems to be a logical assumption, given what is stated in the documentation. If this is not guaranteed, then I'll have to rethink how I go about initializing data for my tests.

On Sunday, January 21, 2018 at 7:40:14 PM UTC-8, Krishnan Mahadevan wrote:

I don’t think the setup methods adhere to that rule. The setup methods are first executed and then some of the test methods may or may not run on that same thread. This is to the best of my understanding.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="HlV7TaQtEgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...> on behalf of Tai Thach <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="HlV7TaQtEgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">tth...@...>
Reply-To: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="HlV7TaQtEgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Date: Monday, January 22, 2018 at 5:20 AM
To: testng-users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="HlV7TaQtEgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Subject: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

I have a suite defined with parallel="classes" and thread-count="2". Based on the documentation:

  • parallel="classes": TestNG will run all the methods in the same class in the same thread, but each class will be run in a separate thread.

I expect that all methods in the same class (setup and test methods) will run in the same thread. However, based on what I see in my log, it appears that the setup method is executing in thread-1 and my test method is executing in thread-2, even though they are both in the same class. What is the correct behavior? Is the documentation wrong?

 

I'm running with TestNG version 6.12. 

Thanks,

Tai

 

 

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="HlV7TaQtEgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="HlV7TaQtEgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: TestNG with parallel = classes behavior inconsistent with documentation

Krishnan Mahadevan

I am not sure about the plans to change it, because I don’t know for sure if it should be changed.

 

Oh btw, can you not use @BeforeMethod to do the setup rather than the @BeforeClass ? AFAIK TestNG guarantees that it would run @BeforeMethod/@Test/@AfterMethod all in the same thread for sure.

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Tai Thach <[hidden email]>
Reply-To: <[hidden email]>
Date: Monday, January 22, 2018 at 9:34 PM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

Thanks, Krishnan for the clarification.

 

Do you know if there are any plans to change this? The reason for this is because I do have a use case where I want to use the setup method(s) to initialize data that is only available to that thread (lets call it thread-1). So if the test method executes in another thread (lets call it thread-2), it cannot find the data that I've initialized in thread-1. 

 

IMHO, with parallel="classes", having all methods of the same class run in the same thread seems to be a logical assumption, given what is stated in the documentation. If this is not guaranteed, then I'll have to rethink how I go about initializing data for my tests.


On Sunday, January 21, 2018 at 7:40:14 PM UTC-8, Krishnan Mahadevan wrote:

I don’t think the setup methods adhere to that rule. The setup methods are first executed and then some of the test methods may or may not run on that same thread. This is to the best of my understanding.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <<a href="javascript:" target="_blank">testng...@...> on behalf of Tai Thach <<a href="javascript:" target="_blank">tth...@...>
Reply-To: <<a href="javascript:" target="_blank">testng...@...>
Date: Monday, January 22, 2018 at 5:20 AM
To: testng-users <<a href="javascript:" target="_blank">testng...@...>
Subject: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

I have a suite defined with parallel="classes" and thread-count="2". Based on the documentation:

  • parallel="classes": TestNG will run all the methods in the same class in the same thread, but each class will be run in a separate thread.

I expect that all methods in the same class (setup and test methods) will run in the same thread. However, based on what I see in my log, it appears that the setup method is executing in thread-1 and my test method is executing in thread-2, even though they are both in the same class. What is the correct behavior? Is the documentation wrong?

 

I'm running with TestNG version 6.12. 

Thanks,

Tai

 

 

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">testng-users...@....
To post to this group, send email to <a href="javascript:" target="_blank">testng...@....
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: TestNG with parallel = classes behavior inconsistent with documentation

Tai Thach
I am using @BeforeMethod (not @BeforeClass) to do the data setup. 

On Monday, January 22, 2018 at 8:09:45 AM UTC-8, Krishnan Mahadevan wrote:

I am not sure about the plans to change it, because I don’t know for sure if it should be changed.

 

Oh btw, can you not use @BeforeMethod to do the setup rather than the @BeforeClass ? AFAIK TestNG guarantees that it would run @BeforeMethod/@Test/@AfterMethod all in the same thread for sure.

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lXSMK1T0AAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...> on behalf of Tai Thach <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lXSMK1T0AAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">tth...@...>
Reply-To: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lXSMK1T0AAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Date: Monday, January 22, 2018 at 9:34 PM
To: testng-users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lXSMK1T0AAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Subject: Re: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

Thanks, Krishnan for the clarification.

 

Do you know if there are any plans to change this? The reason for this is because I do have a use case where I want to use the setup method(s) to initialize data that is only available to that thread (lets call it thread-1). So if the test method executes in another thread (lets call it thread-2), it cannot find the data that I've initialized in thread-1. 

 

IMHO, with parallel="classes", having all methods of the same class run in the same thread seems to be a logical assumption, given what is stated in the documentation. If this is not guaranteed, then I'll have to rethink how I go about initializing data for my tests.


On Sunday, January 21, 2018 at 7:40:14 PM UTC-8, Krishnan Mahadevan wrote:

I don’t think the setup methods adhere to that rule. The setup methods are first executed and then some of the test methods may or may not run on that same thread. This is to the best of my understanding.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Tai Thach <[hidden email]>
Reply-To: <[hidden email]>
Date: Monday, January 22, 2018 at 5:20 AM
To: testng-users <[hidden email]>
Subject: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

I have a suite defined with parallel="classes" and thread-count="2". Based on the documentation:

  • parallel="classes": TestNG will run all the methods in the same class in the same thread, but each class will be run in a separate thread.

I expect that all methods in the same class (setup and test methods) will run in the same thread. However, based on what I see in my log, it appears that the setup method is executing in thread-1 and my test method is executing in thread-2, even though they are both in the same class. What is the correct behavior? Is the documentation wrong?

 

I'm running with TestNG version 6.12. 

Thanks,

Tai

 

 

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="lXSMK1T0AAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="lXSMK1T0AAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: TestNG with parallel = classes behavior inconsistent with documentation

Krishnan Mahadevan

That should then cause the thread to be the same. Do you have a sample that you can share which will reproduce the problem ?

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Tai Thach <[hidden email]>
Reply-To: <[hidden email]>
Date: Monday, January 22, 2018 at 10:06 PM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

I am using @BeforeMethod (not @BeforeClass) to do the data setup. 

On Monday, January 22, 2018 at 8:09:45 AM UTC-8, Krishnan Mahadevan wrote:

I am not sure about the plans to change it, because I don’t know for sure if it should be changed.

 

Oh btw, can you not use @BeforeMethod to do the setup rather than the @BeforeClass ? AFAIK TestNG guarantees that it would run @BeforeMethod/@Test/@AfterMethod all in the same thread for sure.

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <<a href="javascript:" target="_blank">testng...@...> on behalf of Tai Thach <<a href="javascript:" target="_blank">tth...@...>
Reply-To: <<a href="javascript:" target="_blank">testng...@...>
Date: Monday, January 22, 2018 at 9:34 PM
To: testng-users <<a href="javascript:" target="_blank">testng...@...>
Subject: Re: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

Thanks, Krishnan for the clarification.

 

Do you know if there are any plans to change this? The reason for this is because I do have a use case where I want to use the setup method(s) to initialize data that is only available to that thread (lets call it thread-1). So if the test method executes in another thread (lets call it thread-2), it cannot find the data that I've initialized in thread-1. 

 

IMHO, with parallel="classes", having all methods of the same class run in the same thread seems to be a logical assumption, given what is stated in the documentation. If this is not guaranteed, then I'll have to rethink how I go about initializing data for my tests.


On Sunday, January 21, 2018 at 7:40:14 PM UTC-8, Krishnan Mahadevan wrote:

I don’t think the setup methods adhere to that rule. The setup methods are first executed and then some of the test methods may or may not run on that same thread. This is to the best of my understanding.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Tai Thach <[hidden email]>
Reply-To: <[hidden email]>
Date: Monday, January 22, 2018 at 5:20 AM
To: testng-users <[hidden email]>
Subject: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

I have a suite defined with parallel="classes" and thread-count="2". Based on the documentation:

  • parallel="classes": TestNG will run all the methods in the same class in the same thread, but each class will be run in a separate thread.

I expect that all methods in the same class (setup and test methods) will run in the same thread. However, based on what I see in my log, it appears that the setup method is executing in thread-1 and my test method is executing in thread-2, even though they are both in the same class. What is the correct behavior? Is the documentation wrong?

 

I'm running with TestNG version 6.12. 

Thanks,

Tai

 

 

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">testng-users...@....
To post to this group, send email to <a href="javascript:" target="_blank">testng...@....
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: TestNG with parallel = classes behavior inconsistent with documentation

Tai Thach
Hi Krishnan,
I'm not able to reproduce this without running it as part of our current build which is a complicated mess with multiple testng.xml files and thousands of test classes. I'll spend another hour or two to see if I can reproduce it with an simpler sample, but I'm not optimistic. :(
Thanks,
Tai

On Monday, January 22, 2018 at 8:37:45 AM UTC-8, Krishnan Mahadevan wrote:

That should then cause the thread to be the same. Do you have a sample that you can share which will reproduce the problem ?

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RyCxMNv1AAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...> on behalf of Tai Thach <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RyCxMNv1AAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">tth...@...>
Reply-To: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RyCxMNv1AAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Date: Monday, January 22, 2018 at 10:06 PM
To: testng-users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RyCxMNv1AAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Subject: Re: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

I am using @BeforeMethod (not @BeforeClass) to do the data setup. 

On Monday, January 22, 2018 at 8:09:45 AM UTC-8, Krishnan Mahadevan wrote:

I am not sure about the plans to change it, because I don’t know for sure if it should be changed.

 

Oh btw, can you not use @BeforeMethod to do the setup rather than the @BeforeClass ? AFAIK TestNG guarantees that it would run @BeforeMethod/@Test/@AfterMethod all in the same thread for sure.

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Tai Thach <[hidden email]>
Reply-To: <[hidden email]>
Date: Monday, January 22, 2018 at 9:34 PM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

Thanks, Krishnan for the clarification.

 

Do you know if there are any plans to change this? The reason for this is because I do have a use case where I want to use the setup method(s) to initialize data that is only available to that thread (lets call it thread-1). So if the test method executes in another thread (lets call it thread-2), it cannot find the data that I've initialized in thread-1. 

 

IMHO, with parallel="classes", having all methods of the same class run in the same thread seems to be a logical assumption, given what is stated in the documentation. If this is not guaranteed, then I'll have to rethink how I go about initializing data for my tests.


On Sunday, January 21, 2018 at 7:40:14 PM UTC-8, Krishnan Mahadevan wrote:

I don’t think the setup methods adhere to that rule. The setup methods are first executed and then some of the test methods may or may not run on that same thread. This is to the best of my understanding.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Tai Thach <[hidden email]>
Reply-To: <[hidden email]>
Date: Monday, January 22, 2018 at 5:20 AM
To: testng-users <[hidden email]>
Subject: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

I have a suite defined with parallel="classes" and thread-count="2". Based on the documentation:

  • parallel="classes": TestNG will run all the methods in the same class in the same thread, but each class will be run in a separate thread.

I expect that all methods in the same class (setup and test methods) will run in the same thread. However, based on what I see in my log, it appears that the setup method is executing in thread-1 and my test method is executing in thread-2, even though they are both in the same class. What is the correct behavior? Is the documentation wrong?

 

I'm running with TestNG version 6.12. 

Thanks,

Tai

 

 

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="RyCxMNv1AAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="RyCxMNv1AAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: TestNG with parallel = classes behavior inconsistent with documentation

Krishnan Mahadevan

Tai,

If you aren’t able to reproduce this error with a simple test, I am guessing that it has got something to do with your test code.

I will let you sort it out. Please do update this thread if you have managed to create a simple test that we can execute to reproduce the problem.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Tai Thach <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, January 24, 2018 at 12:35 AM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

Hi Krishnan,

I'm not able to reproduce this without running it as part of our current build which is a complicated mess with multiple testng.xml files and thousands of test classes. I'll spend another hour or two to see if I can reproduce it with an simpler sample, but I'm not optimistic. :(

Thanks,

Tai

On Monday, January 22, 2018 at 8:37:45 AM UTC-8, Krishnan Mahadevan wrote:

That should then cause the thread to be the same. Do you have a sample that you can share which will reproduce the problem ?

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <<a href="javascript:" target="_blank">testng...@...> on behalf of Tai Thach <<a href="javascript:" target="_blank">tth...@...>
Reply-To: <<a href="javascript:" target="_blank">testng...@...>
Date: Monday, January 22, 2018 at 10:06 PM
To: testng-users <<a href="javascript:" target="_blank">testng...@...>
Subject: Re: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

I am using @BeforeMethod (not @BeforeClass) to do the data setup. 

On Monday, January 22, 2018 at 8:09:45 AM UTC-8, Krishnan Mahadevan wrote:

I am not sure about the plans to change it, because I don’t know for sure if it should be changed.

 

Oh btw, can you not use @BeforeMethod to do the setup rather than the @BeforeClass ? AFAIK TestNG guarantees that it would run @BeforeMethod/@Test/@AfterMethod all in the same thread for sure.

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Tai Thach <[hidden email]>
Reply-To: <[hidden email]>
Date: Monday, January 22, 2018 at 9:34 PM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

Thanks, Krishnan for the clarification.

 

Do you know if there are any plans to change this? The reason for this is because I do have a use case where I want to use the setup method(s) to initialize data that is only available to that thread (lets call it thread-1). So if the test method executes in another thread (lets call it thread-2), it cannot find the data that I've initialized in thread-1. 

 

IMHO, with parallel="classes", having all methods of the same class run in the same thread seems to be a logical assumption, given what is stated in the documentation. If this is not guaranteed, then I'll have to rethink how I go about initializing data for my tests.


On Sunday, January 21, 2018 at 7:40:14 PM UTC-8, Krishnan Mahadevan wrote:

I don’t think the setup methods adhere to that rule. The setup methods are first executed and then some of the test methods may or may not run on that same thread. This is to the best of my understanding.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Tai Thach <[hidden email]>
Reply-To: <[hidden email]>
Date: Monday, January 22, 2018 at 5:20 AM
To: testng-users <[hidden email]>
Subject: [testng-users] TestNG with parallel = classes behavior inconsistent with documentation

 

I have a suite defined with parallel="classes" and thread-count="2". Based on the documentation:

  • parallel="classes": TestNG will run all the methods in the same class in the same thread, but each class will be run in a separate thread.

I expect that all methods in the same class (setup and test methods) will run in the same thread. However, based on what I see in my log, it appears that the setup method is executing in thread-1 and my test method is executing in thread-2, even though they are both in the same class. What is the correct behavior? Is the documentation wrong?

 

I'm running with TestNG version 6.12. 

Thanks,

Tai

 

 

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">testng-users...@....
To post to this group, send email to <a href="javascript:" target="_blank">testng...@....
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.