Is invocation order guaranteed for multiple implementations of a particular listener?

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

Is invocation order guaranteed for multiple implementations of a particular listener?

Raj Srivastava
If I have 3 implementations of ITestListener, is it guaranteed that they will be invoked in a particular order ?
As far as I knew, the order is not guaranteed.
But changing the order of these classes while specifying them in META-INF/services/org.testng.ITestListener does seem to change the order in which they are getting invoked.

If it is guaranteed, what about the cases where one implementation is mentioned in @Listeners, one in maven-surefire-plugin configuration, and one as mentioned above?

--
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: Is invocation order guaranteed for multiple implementations of a particular listener?

Krishnan Mahadevan
Invocation order is not guaranteed for listeners. If all listeners are being wired in via a ServiceLoader then order is kind of maintained. 

If you are looking at maintaining order you can refer to my blog on this : 
https://rationaleemotions.wordpress.com/2016/12/26/dears-listeners-stand-in-q-please/

But even the approach I talk about in my blog, has caveats. 

On Thu, Mar 29, 2018, 03:02 Raj Srivastava <[hidden email]> wrote:
If I have 3 implementations of ITestListener, is it guaranteed that they will be invoked in a particular order ?
As far as I knew, the order is not guaranteed.
But changing the order of these classes while specifying them in META-INF/services/org.testng.ITestListener does seem to change the order in which they are getting invoked.

If it is guaranteed, what about the cases where one implementation is mentioned in @Listeners, one in maven-surefire-plugin configuration, and one as mentioned above?

--
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.
--

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/

--
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: Is invocation order guaranteed for multiple implementations of a particular listener?

Scott Babcock
I have a TestNG library that includes a ListenerChain class that guarantees execution order. Find the GitHub here: https://github.com/Nordstrom/TestNG-Foundation
You can declare your listeners in a class-level annotation or in a service loader provider file.

On Wednesday, March 28, 2018 at 6:08:59 PM UTC-7, Krishnan Mahadevan wrote:
Invocation order is not guaranteed for listeners. If all listeners are being wired in via a ServiceLoader then order is kind of maintained. 

If you are looking at maintaining order you can refer to my blog on this : 
<a href="https://rationaleemotions.wordpress.com/2016/12/26/dears-listeners-stand-in-q-please/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frationaleemotions.wordpress.com%2F2016%2F12%2F26%2Fdears-listeners-stand-in-q-please%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFVaexfKRSzACeHICyqo-OUWRl3lQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frationaleemotions.wordpress.com%2F2016%2F12%2F26%2Fdears-listeners-stand-in-q-please%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFVaexfKRSzACeHICyqo-OUWRl3lQ&#39;;return true;">https://rationaleemotions.wordpress.com/2016/12/26/dears-listeners-stand-in-q-please/

But even the approach I talk about in my blog, has caveats. 

On Thu, Mar 29, 2018, 03:02 Raj Srivastava <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="guGuVhuVAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rajsriva...@...> wrote:
If I have 3 implementations of ITestListener, is it guaranteed that they will be invoked in a particular order ?
As far as I knew, the order is not guaranteed.
But changing the order of these classes while specifying them in META-INF/services/org.testng.ITestListener does seem to change the order in which they are getting invoked.

If it is guaranteed, what about the cases where one implementation is mentioned in @Listeners, one in maven-surefire-plugin configuration, and one as mentioned above?

--
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="guGuVhuVAgAJ" 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="guGuVhuVAgAJ" 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.
--

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/

--
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.