Ori Marko
Ori Marko

Reputation: 58774

TestNG groups doesn't execute @BeforeMethod

I follow tutorial to execute TestNG groups in Eclipse

The problem it doesn't execute @BeforeMethod method which setup data so all tests in group failed

Method is executed when running test(s) regular,meaning each test or all tests in class

Is it limitation of TestNG or I'm missing something?

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

Upvotes: 1

Views: 573

Answers (1)

Rahul L
Rahul L

Reputation: 4349

You will need to add "alwaysRun=true" in configuration methods if they need to be executed irrespective of group.

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

Upvotes: 4

Related Questions