Reputation: 45
I'm writing test cases using TestNG.I want run a particular method after every failure test case.is there any way to run that method after every failure case?
Upvotes: 1
Views: 732
Reputation: 4035
You can implement a method something with alwaysRun tag,
@Test(alwaysRun = true)
public void def()
{
-----
}
It can be any annotation: Test, AfterTest, AfterClass
Upvotes: 1
Reputation: 4507
You can use ITestListener interface when you want to run a particular method after your test case failure.
You can find the ITestListener doc here: http://static.javadoc.io/org.testng/testng/6.11/org/testng/ITestListener.html
And you can refer to the following link for its implementation, its very helpful !! https://www.toolsqa.com/selenium-webdriver/testng-listeners/
Upvotes: 2