Ask help for the listener execution order

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

Ask help for the listener execution order

ilovepumpkin.shen
I wanted to add some application information (like url, username, etc.) and the host information into the emailable-report.html which is generated by TestNG by default. So I wrote a listener class which extends IReporter.java and put it in <listeners> of my testng.xml. And in my listener class, I read emailable-report.html content and modify it then save it back.

I presumed that the default TestNG listeners are always run before user defined listeners but it seems that I am wrong. I found emailable-report.html is generated before my listener is invoked sometimes but sometimes not. The listeners run in a random order? 

I also tried to set useDefaultListeners="false" in the ant build file and define all the TestNG listeners and my listener in testng.xml like below.
<listeners>
<listener class-name="org.testng.reporters.EmailableReporter" />
<listener class-name="test.MyReporter" />
<listener class-name="org.testng.reporters.TestHTMLReporter" />
<listener class-name="org.testng.reporters.SuiteHTMLReporter" />
</listeners>
But it does not help anything - it still work sometimes.

Is there any way for me ensure my listener runs after org.testng.reporters.EmailableReporter ? 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/gmE54u9UdvEJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Ask help for the listener execution order

⇜Krishnan Mahadevan⇝
Ordering of listeners invocation is NEVER guaranteed.


So you have two options :

1. Within your reporter, invoke the logic explicitly.
2. Within your reporter, introduce a wait, which holds on till the EmailableReporter is done with its execution, and then kick start your listener.


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/


On Thu, Jan 10, 2013 at 2:27 PM, <[hidden email]> wrote:
I wanted to add some application information (like url, username, etc.) and the host information into the emailable-report.html which is generated by TestNG by default. So I wrote a listener class which extends IReporter.java and put it in <listeners> of my testng.xml. And in my listener class, I read emailable-report.html content and modify it then save it back.

I presumed that the default TestNG listeners are always run before user defined listeners but it seems that I am wrong. I found emailable-report.html is generated before my listener is invoked sometimes but sometimes not. The listeners run in a random order? 

I also tried to set useDefaultListeners="false" in the ant build file and define all the TestNG listeners and my listener in testng.xml like below.
<listeners>
<listener class-name="org.testng.reporters.EmailableReporter" />
<listener class-name="test.MyReporter" />
<listener class-name="org.testng.reporters.TestHTMLReporter" />
<listener class-name="org.testng.reporters.SuiteHTMLReporter" />
</listeners>
But it does not help anything - it still work sometimes.

Is there any way for me ensure my listener runs after org.testng.reporters.EmailableReporter ? 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/gmE54u9UdvEJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

--
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 http://groups.google.com/group/testng-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Ask help for the listener execution order

Hemanathan Vasu
Hi,

   Can we change the data structure for listener objects in suiteRunner [instead of HashMap, LinkedHashMap can be used.] so that the sequence of listeners gets loaded and listeners will be executed in order specified by the user.

Thanks
Hemanathan


On Sunday, February 10, 2013 at 11:30:58 AM UTC+5:30, Krishnan Mahadevan wrote:
Ordering of listeners invocation is NEVER guaranteed.

Take a look at here : <a onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F11084157%2Fis-there-a-way-to-define-the-runorder-of-two-different-testng-listeners\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFxO03ELKOleT3SlI8c0eWuvpirNA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F11084157%2Fis-there-a-way-to-define-the-runorder-of-two-different-testng-listeners\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFxO03ELKOleT3SlI8c0eWuvpirNA&#39;;return true;" href="http://stackoverflow.com/questions/11084157/is-there-a-way-to-define-the-runorder-of-two-different-testng-listeners" target="_blank" rel="nofollow">http://stackoverflow.com/questions/11084157/is-there-a-way-to-define-the-runorder-of-two-different-testng-listeners

So you have two options :

1. Within your reporter, invoke the logic explicitly.
2. Within your reporter, introduce a wait, which holds on till the EmailableReporter is done with its execution, and then kick start your listener.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a 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;" href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow">http://wakened-cognition.blogspot.com/


On Thu, Jan 10, 2013 at 2:27 PM, <<a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="jkqQGlWvs1EJ">ilovepum...@...> wrote:
I wanted to add some application information (like url, username, etc.) and the host information into the emailable-report.html which is generated by TestNG by default. So I wrote a listener class which extends IReporter.java and put it in <listeners> of my testng.xml. And in my listener class, I read emailable-report.html content and modify it then save it back.

I presumed that the default TestNG listeners are always run before user defined listeners but it seems that I am wrong. I found emailable-report.html is generated before my listener is invoked sometimes but sometimes not. The listeners run in a random order? 

I also tried to set useDefaultListeners="false" in the ant build file and define all the TestNG listeners and my listener in testng.xml like below.
<listeners>
<listener class-name="org.testng.reporters.EmailableReporter" />
<listener class-name="test.MyReporter" />
<listener class-name="org.testng.reporters.TestHTMLReporter" />
<listener class-name="org.testng.reporters.SuiteHTMLReporter" />
</listeners>
But it does not help anything - it still work sometimes.

Is there any way for me ensure my listener runs after org.testng.reporters.EmailableReporter ? 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit <a onmousedown="this.href=&#39;https://groups.google.com/d/msg/testng-users/-/gmE54u9UdvEJ&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msg/testng-users/-/gmE54u9UdvEJ&#39;;return true;" href="https://groups.google.com/d/msg/testng-users/-/gmE54u9UdvEJ" target="_blank" rel="nofollow">https://groups.google.com/d/msg/testng-users/-/gmE54u9UdvEJ.
To post to this group, send email to <a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="jkqQGlWvs1EJ">testng...@....
To unsubscribe from this group, send email to <a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="jkqQGlWvs1EJ">testng-users...@googlegroups.com.
For more options, visit this group at <a onmousedown="this.href=&#39;http://groups.google.com/group/testng-users?hl\x3den&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/testng-users?hl\x3den&#39;;return true;" href="http://groups.google.com/group/testng-users?hl=en" target="_blank" rel="nofollow">http://groups.google.com/group/testng-users?hl=en.

--
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: Ask help for the listener execution order

⇜Krishnan Mahadevan⇝
Sure. Why not send the TestNG codebase a pull request with the proposed changes? We would be happy to help you get it merged.

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 Scribblings @ http://rationaleemotions.wordpress.com/

On Tue, Jul 17, 2018 at 10:22 AM, Hemanathan Vasu <[hidden email]> wrote:
Hi,

   Can we change the data structure for listener objects in suiteRunner [instead of HashMap, LinkedHashMap can be used.] so that the sequence of listeners gets loaded and listeners will be executed in order specified by the user.

Thanks
Hemanathan


On Sunday, February 10, 2013 at 11:30:58 AM UTC+5:30, Krishnan Mahadevan wrote:
Ordering of listeners invocation is NEVER guaranteed.


So you have two options :

1. Within your reporter, invoke the logic explicitly.
2. Within your reporter, introduce a wait, which holds on till the EmailableReporter is done with its execution, and then kick start your listener.


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/


On Thu, Jan 10, 2013 at 2:27 PM, <[hidden email]> wrote:
I wanted to add some application information (like url, username, etc.) and the host information into the emailable-report.html which is generated by TestNG by default. So I wrote a listener class which extends IReporter.java and put it in <listeners> of my testng.xml. And in my listener class, I read emailable-report.html content and modify it then save it back.

I presumed that the default TestNG listeners are always run before user defined listeners but it seems that I am wrong. I found emailable-report.html is generated before my listener is invoked sometimes but sometimes not. The listeners run in a random order? 

I also tried to set useDefaultListeners="false" in the ant build file and define all the TestNG listeners and my listener in testng.xml like below.
<listeners>
<listener class-name="org.testng.reporters.EmailableReporter" />
<listener class-name="test.MyReporter" />
<listener class-name="org.testng.reporters.TestHTMLReporter" />
<listener class-name="org.testng.reporters.SuiteHTMLReporter" />
</listeners>
But it does not help anything - it still work sometimes.

Is there any way for me ensure my listener runs after org.testng.reporters.EmailableReporter ? 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/gmE54u9UdvEJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

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