Retry failed tests

2,848 views
Skip to first unread message

Lévay Szabolcs

unread,
Jan 22, 2014, 4:12:34 AM1/22/14
to spec...@googlegroups.com

There is a way to implement an AfterScenario hook to re-run 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.

Gáspár Nagy

unread,
Jan 22, 2014, 5:11:29 AM1/22/14
to spec...@googlegroups.com
No. Unfortunately this is not really possible right now.

The tests are scheduled by the test runner, not SpecFlow itself. SpecRun can retry the failing tests.

Oliver Friedrich

unread,
Jan 22, 2014, 5:21:44 AM1/22/14
to spec...@googlegroups.com
I'm not aware of a solution to this problem from inside the running scenario.

We also implemented this feature some time ago, and used the following approach:
  1. For every failed test, write the test case name including the containing class name and the namespace to a file.
  2. Using nunit-console.exe, rerun the whole spec dll but filtered by that text file, so NUnit will run only the failed tests.

In a continuous integration scenario, this was not so hard to set up.

Later, we found out that SpecRun reruns failed tests automatically, but we had other problems with it (that might totally be due to our setup). But you could give it a try.


--
Rodziną do Jana Pawła II. - www.rodzinadojp2.pl


2014/1/22 Lévay Szabolcs <levays...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Lévay Szabolcs

unread,
Jan 23, 2014, 2:31:48 AM1/23/14
to spec...@googlegroups.com
Thank you guys for the quick response!

Have a nice day!

LaTisha Krystof

unread,
Feb 13, 2016, 2:29:51 AM2/13/16
to SpecFlow
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

LaTisha Krystof

unread,
Feb 13, 2016, 2:29:51 AM2/13/16
to SpecFlow
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



On Wednesday, January 22, 2014 at 1:12:34 AM UTC-8, Szabolcs Lévay wrote:

Prateek Agarwal

unread,
Mar 10, 2019, 11:38:18 AM3/10/19
to SpecFlow
Any idea how to rerun failed test cases in Specflow with C# ?
I tried to use all the available plugs-in but none of them worked out for me.

Henrry Salinas

unread,
Mar 11, 2019, 9:15:27 AM3/11/19
to spec...@googlegroups.com
Hi,

You most likely have to have a custom implementation of the retryattribute, please check retry-on-exception-by-default



For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages