How to run failed test cases in TestNg code example

Example 1: run failed test cases in testng

I would use testng-failed.xml file to execute
failed test cases
1. After the first run of an automated test run.
Right click on Project and click on Refresh

2. A folder will be generated named
“test-output” folder. Inside “test-output”
folder, you could find “testng-failed.xml”

3. Run “testng-failed.xml” to execute 
the failed test cases again. Right-click
on this file and click on run as and 
select the option called "testNG suite".

Example 2: why testing failed test cases

-> Why we would want to rerun the failed test cases?
	- If a bunch of tests are failing from a
    big regression suite, we don't want to
    rerun the whole suite again.
	-> Therefore we just re-run the failed tests to
    make sure those tests are actually failing and
    it is not a syncronization issue

Tags:

Misc Example