How to force TestNG create new instance of test class for each method if run mode is parallel=\"methods\"
?
JUnit does it automatically but TestNG reuses
I've used TestNG to run multiple selenium webdriver tests in parallel. To set up a new WebDriver for each method, use the @DataProvider annotation and its associated attribute in the @Test annotation.
Checkout Factory
From javadoc:
Marks a method as a factory that returns objects that will be used by TestNG as Test classes. The method must return Object[].
There is no way to force testng to do that. A solution is to set webdriver instance to a threadlocal variable. What this would help doing is, it would create one webdriver object per thread, if u do a get on the variable, it. Would give u that thread's object only.