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

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

by mukil :: Rate this Message:

| View in Thread


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.

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