@DataProvider和@BeforeMethod订单

时间:2013-08-11 22:30:02

标签: java selenium webdriver testng

使用testng注释在测试类中首先调用哪种方法:

  
      
  • 使用@DataProvider
  • 进行注释   
  • 使用@BeforeMethod
  • 进行注释   

在测试期间,我找到了订单:1。@DataProvider 2. @BeforeMethod

但我的@DataProvider使用仅在@BeforeMethod中初始化的变量。 哪种解决方法可能是最好的?

我的情况如下:

class Test 
  @BeforeClass
    //here I initialize pages (pageobjects in context of selenium)
  @BeforeMethod
    //here i 'get' the page I want (and the one i'll use in dataprovider)

  @Test(dataProvider = "dp")
    //my test goes here...

  @DataProvider
  dp
    //here I use page. The page may be 'usable' only if it was already 'get'.

1 个答案:

答案 0 :(得分:0)

删除@BeforeMethod注释,将其设为private,然后从数据提供商处明确调用。

相关问题