【问题标题】:TestNG groups doesn't execute @BeforeMethodTestNG 组不执行 @BeforeMethod
【发布时间】:2020-12-23 14:02:37
【问题描述】:

我跟随tutorial在Eclipse中执行TestNG组

它不执行设置数据的@BeforeMethod方法的问题,所以组中的所有测试都失败了

在常规运行测试时执行方法,即类中的每个测试或所有测试

是 TestNG 的限制还是我遗漏了什么?

@BeforeMethod
public void setup() { } //...    
@Test(groups = { "mygroup" })
public void testMyGroup1() { }//...
@Test(groups = { "mygroup" })
public void testMyGroup2() { }//...
public void testNotInGroup() { }//...

【问题讨论】:

    标签: java unit-testing testng


    【解决方案1】:

    如果需要在不考虑组的情况下执行配置方法,则需要在配置方法中添加“alwaysRun=true”。

    @BeforeMethod(alwaysRun = true)
    public void setup() { } //...
    

    【讨论】:

      猜你喜欢
      • 2015-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-21
      • 1970-01-01
      • 1970-01-01
      • 2017-07-29
      相关资源
      最近更新 更多