Giri
Giri

Reputation: 411

Reusing @Test methods in testNG file

I have @Test method which needs to be re-executed after running few other @Test methods in testNG file. How can i achive this.

Please note i can t use other annotation like @BeforeTest @AfterTest in my set-up

@runTest
@VerifyPage
@VerifyTable
@runTest

Upvotes: 0

Views: 941

Answers (1)

juherr
juherr

Reputation: 5740

As said on repeating test cases using testng in specific order TestA -> TestB -> TestC -> TestA -> TestD

It is not possible to run the same test many times during one run.

Instead, you can have:

TestA -> TestB -> TestC -> TestD -> TestX -> TestY

where TestD and TestY are just calling TestA and TestC methods.

Then, you just have to configure dependency between methods: http://testng.org/doc/documentation-main.html#dependent-methods

So in your case, combined with dependsOnMethods:

@runTest
@VerifyPage
@VerifyTable
@runTest2 // which will just call @runTest method

Upvotes: 2

Related Questions