首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >@DataProvider和@BeforeMethod order

@DataProvider和@BeforeMethod order
EN

Stack Overflow用户
提问于 2013-08-11 22:30:02
回答 1查看 4.2K关注 0票数 3

在具有testng注释的测试类中首先调用什么方法:

  • 带@DataProvider注释
  • 带@BeforeMethod注解

在我的测试中,我找到了顺序: 1. @DataProvider 2. @BeforeMethod

但是,我的@DataProvider使用了仅在@BeforeMethod中初始化的变量。这里最好的办法是什么?

我的情况如下:

代码语言:javascript
复制
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'.
EN

回答 1

Stack Overflow用户

发布于 2014-09-02 11:52:37

删除@BeforeMethod注释,使其为private,并从数据提供程序中显式调用它。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18177359

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档