Search code examples
testngtestng-eclipse

How to run a particular method if my test case failed(using TestNG)?


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?


Solution

  • 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/