Read testContext information at runtime

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

Read testContext information at runtime

Dipesh Patel
TestNG - Framework

Listener Class extend testbase and implements ITestListener

In Testbase class a method with a @beforeMethod annotation which will initialise necessary instance; including ExtentTest as below;


Listener class is having onStart, onSuccess, onFailure, onSkipped. I would like to access the instance on runtime so I can report accordingly.


I have tried setting the attribute
testContext.setAttribute("extent", extentTest);

but unable to retrieve using
testContext.getAttribute("extent");


I have a private class called TestContext for ExtentReport as below;

Can someone please give me a direction to read the instance set in beforemethod from Listener class methods?

--
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: Read testContext information at runtime

⇜Krishnan Mahadevan⇝
Dipesh,

Its hard to figure out whats going with screenshots of your code. Can you please help create a simple standalone example which can be used to reproduce your problem [ preferably one that doesnt depend on any external libraries such as Extent Reports for.g., ]

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 31, 2018 at 2:39 PM, Dipesh Patel <[hidden email]> wrote:
TestNG - Framework

Listener Class extend testbase and implements ITestListener

In Testbase class a method with a @beforeMethod annotation which will initialise necessary instance; including ExtentTest as below;


Listener class is having onStart, onSuccess, onFailure, onSkipped. I would like to access the instance on runtime so I can report accordingly.


I have tried setting the attribute
testContext.setAttribute("extent", extentTest);

but unable to retrieve using
testContext.getAttribute("extent");


I have a private class called TestContext for ExtentReport as below;

Can someone please give me a direction to read the instance set in beforemethod from Listener class methods?

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