How to force TestNG create new instance of test class for each method if run mode is parallel=“methods”

前端 未结 3 611
暖寄归人
暖寄归人 2021-01-01 19:26

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

相关标签:
3条回答
  • 2021-01-01 20:05

    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.

    0 讨论(0)
  • 2021-01-01 20:13

    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[].
    
    0 讨论(0)
  • 2021-01-01 20:14

    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.

    0 讨论(0)
提交回复
热议问题