How to Rerun Nunit failed test

Nunit provides a Retry attribute to run the failed test method with a number of times.

[Retry(number of times)]
[Test]
[Retry(2)]
public void login()
{
}

 

Then another thought of fetching failed test and retrying is through parsing the output XML.

The test report file .xml contains the complete report of the Test execution.

We can write c# the code to parse the XML to find the failed test method with the class name.

test-case id="0-1002" name="loginMethod" fullname="SeleniumNunit.test.LoginTest.loginMethod" methodname="loginMethod" classname="SeleniumNunit.test.LoginTest" runstate="Runnable" seed="990942393" result="Failed" start-time="2020-08-01 02:18:28Z" end-time="2020-08-01 02:18:37Z" duration="8.233454" asserts="0"

 

 

Related Tutorials