SpecFlow - Retry failed tests

LeeWay picture LeeWay · Jan 22, 2014 · Viewed 7.5k times · Source

Is there a way to implement an AfterScenario hook to re-run the current test in case of Fail?

Something like this:

[AfterScenario("retry")]
public void Retry()
{
    if (ScenarioContext.Current.TestError != null)
    {
     // ?     
    }
}

Note: The tests in my project are combined in Ordered tests and executed via MsTest.

Answer

LaTisha picture LaTisha · Feb 13, 2016

This plugin is awesome. https://github.com/arrty/specflow-retry. I got it to work with nunit and his example is using MS-Test

It will allow you to do this:

@retry:2
Scenario: Tag on scenario is preferred
Then scenario should be run 3 times