Executing Failed TestCases in Selenium using TestNG – User friendly Tech help

Scenario:-
nWe want to re-run only the failed testcases in selenium, rather than running the entire suite.
n
nApproach:-
nEvery time tests fail in a suite, TestNG creates a file called testng-failed.xml in the output directory. This XML file contains the necessary information to rerun only these methods that failed, utlizing this we can easily rerun the failed tests without having to run the entire test suite.
n
nNote:- For running the test exactly after the failure we need to call the method that failed. We can get that method name from  IRetryAnalyzer interface . If we just want to rerun all the failed test cases together, then we can give the testng-failed.xml as input xml after the first execution.But remember this will result in creation of 2 reports, one of previous run + latest run of the failed test cases, rather than having the consolidated report
n
nSolution:-
nLocate the testng-failed.xml file
nProject->test-output->testng-failed.xmln

n

n

n

n

n

n

n

opening testng-failed

n

nRerun this file to execute only the failed test cases.
n(Open file -> CTRL+F11)
n

n

n

n

n

n

n

n

n

testng-failed.xml file view

n

How to run parallel Selenium Tests

Was this article helpful?
YesNo

Similar Posts