« Return to Thread: How to create Thread Local object using TestNG before and after methods

Re: How to create Thread Local object using TestNG before and after methods

by Krishnan Mahadevan :: Rate this Message:

| View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.
You might want to read a bit About ThreasLocal variables in Java. That should help you answer your own qn. 

On Thursday, May 24, 2012, mukil wrote:

How do i create and destroy thread local object using TestNG.

Scenario :-

          I have browser object created for every test method , i do
not want to create explicitly inside test methods, instead i want to
create & destroy using BEFOREMETHOD and AFTERMETHOD how do i achieve
this. Below code works fine in a Single thread , but when i execute as
parallel-method it fails


@BeforeMethod()
public void bm(ITestContext context){
 context.setAttribute("BROWSER",new Browser());
}

@Test
piblic void mytest(ITestContext context){
....
.... access browser obj
}

@BeforeMethod()
public void bm(ITestContext context){
 context.setAttribute("BROWSER",null);
}

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@....
To unsubscribe from this group, send email to testng-users+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.



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

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@....
To unsubscribe from this group, send email to testng-users+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

 « Return to Thread: How to create Thread Local object using TestNG before and after methods