Trigger tests from event listenter - rerun failed tests

66 views
Skip to first unread message

אסף משעל

unread,
Dec 15, 2016, 3:41:01 AM12/15/16
to NUnit-Discuss
Hello all,

I want to trigger a test that failed immediately after it failed - means that if the test failed it will rerun the same test immediately again.
I used this command if TearDown method:
TestExecutionContext.CurrentContext.CurrentTest.Run(new EventListener(), TestFilter.Empty);

This command will rerun the test again in case this command is in TearDown method in the test itself.
But if I will try in inside TestFinished method inside the EventListenter so I will get null value inside CurrentTest Property(TestExecutionContext.CurrentContext.CurrentTest=null).

I want to rerun failed tests from TestFinished method inside EventListener.

Does someone know how to do that?

Thanks,
Assaf.

Charlie Poole

unread,
Dec 15, 2016, 12:19:45 PM12/15/16
to NUnit-Discuss
Hi Assaf,

You are trying to call NUnit internal methods from within your test.
To compile, you even had to add a `using` statement for the Internal
namespace. That's not going to work. These internal classes are
intended for NUnit itself to use, within the proper context and with
proper preparation. Having a test that is still running (TearDown
__is__ part of the test) try to restart itself is not one of those
intended uses.

If you simply want to retry the test on failure, why not just use the
Retry attribugte?

Charlie
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nunit-discus...@googlegroups.com.
> To post to this group, send email to nunit-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/nunit-discuss.
> For more options, visit https://groups.google.com/d/optout.

אסף משעל

unread,
Dec 18, 2016, 6:21:24 AM12/18/16
to NUnit-Discuss
Hello Charlie,

Thanks for  you answering :)
Do you mean NUnit-retry 1.1.0 nuget package? if yes - it is only available for NUnit 2.6.3 version.

Thanks,
Assaf.

בתאריך יום חמישי, 15 בדצמבר 2016 בשעה 19:19:45 UTC+2, מאת charlie:

אסף משעל

unread,
Dec 18, 2016, 6:45:19 AM12/18/16
to NUnit-Discuss
Hello Charlie,
I saw that in version 3 we have the retry attribute. 
I'm using NUnit 2.6.4. Do you know if there is any mechanism for 2.6.4?

Thanks,
Assaf.

בתאריך יום ראשון, 18 בדצמבר 2016 בשעה 13:21:24 UTC+2, מאת אסף משעל:

Charlie Poole

unread,
Dec 18, 2016, 6:50:17 AM12/18/16
to NUnit-Discuss
RetryAttribute was added in nunit 3.


To unsubscribe from this group and stop receiving emails from it, send an email to nunit-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages