SK176H
SK176H

Reputation: 1319

How to override TestNG pass or fail result

Upvotes: 0

Views: 1424

Answers (1)

Jaroslav Cincera
Jaroslav Cincera

Reputation: 1036

Instead of duplicating test methods I would recommend to use org.testng.IRetryAnalyzer which basically runs failed test again. You can see some example here http://seleniumeasy.com/testng-tutorials/execute-only-failed-test-cases-using-iretryanalyzer.

But if you really want to override result you can use listeners and implement methods in which you get ITestResult. In this object you can check method class/name/result/etc. and change some of these attributes (including result).

http://testng.org/javadocs/org/testng/ITestListener.html http://testng.org/javadocs/org/testng/IInvokedMethodListener.html

or for whole test suite

http://testng.org/javadocs/org/testng/ISuiteListener.html

Upvotes: 1

Related Questions