Re: [testng-users] How to invoke TestNG Reporter.log specific to thread running!

178 views
Skip to first unread message

Krishnan Mahadevan

unread,
Jan 30, 2013, 11:47:50 PM1/30/13
to testng...@googlegroups.com
Try this and see if that helps :

ITestResult result = Reporter.getCurrentTestResult();

List<String> output = Reporter.getOutput(result)


Thanks & Regards
Krishnan Mahadevan

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



On Thu, Jan 31, 2013 at 4:54 AM, Gaurav Khandelwal <gaurav.k...@virginamerica.com> wrote:
I have done some silly stuffs, created a web application with Struts2 and using selenium to automate the browser actions and TestNG for reporting and managing multi-threading.

Than I wanted to fetch the logs generated by TestNG Reporter specific to the tests I am running, so I have used:
Reporter.getOutput()
for accessing the logs and it is working fine for me.

But the problem is, it is returning me all the logs which includes the results of 10 tests I have executed before this. It is keep on appending the logs to the same Reporter and returns me the result.

Please suggest some better way to manage the logs, so that I can access them based on the automated process going on.

Thanks!

--
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 testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Gaurav Khandelwal

unread,
Feb 5, 2013, 6:18:38 PM2/5/13
to testng...@googlegroups.com
Thanks Krishnan,

My problem is getCurrentTestResult is not giving me the right ITestResult object, as I am trying to access it through different thread.
I want to store some unique id to the threads and based in the same I want to access the specific logs from Reporter. Is that possible..?

Krishnan Mahadevan

unread,
Feb 10, 2013, 12:38:35 PM2/10/13
to testng...@googlegroups.com
getCurrentTestResult is going to work fine only when invoked from within the current Thread. If you need the current test method's ITestResult object, then I would suggest that you push this value into a collection [set/map/list] and then get the value from the other thread that you would like to access it. You could adopt a Singleton class which basically does the task of acting as the mediator between the test thread and the other thread.

Thanks & Regards
Krishnan Mahadevan

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

--
Reply all
Reply to author
Forward
0 new messages