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?
Asked
Active
Viewed 403 times
2 Answers
2
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/

Sameer Arora
- 4,439
- 3
- 10
- 20
1
You can implement a method something with alwaysRun tag,
@Test(alwaysRun = true)
public void def()
{
-----
}
It can be any annotation: Test, AfterTest, AfterClass

Ishita Shah
- 3,955
- 2
- 27
- 51