Retry attribute is not working as expected

182 views
Skip to first unread message

Khajakhaleelulla Shaik

unread,
Nov 25, 2019, 7:22:30 PM11/25/19
to NUnit-Discuss
Hi Team,

We are using C# Selenium and NUnit framework for our test automation. Sometimes some test cases will fail in dev environment during execution due environmental issues. I was trying to re-run the failed ones, by using Retry attribute. But it didn't work ( I have kept assertion failures as well)

Could you please have a look and let us know.

Thanks, Khaja Shaik.

Oskar Berggren

unread,
Nov 25, 2019, 9:44:44 PM11/25/19
to nunit-...@googlegroups.com
I'm not an expert on the subject but the documentation is here:

I suspect that those that are expects might wonder what exactly to have a look at. It is probably helpful if you can show some code and test output?

/Oskar

Khajakhaleelulla Shaik

unread,
Nov 28, 2019, 12:37:31 PM11/28/19
to NUnit-Discuss
Hi,

Please find the sample code.

TestFixture]


    public class UITests : BaseClassProtractor
    {

        [SetUp]


        public void Setup()
        {
            //**Call chrome driver and open app url set up**//


   }
[Test]
[Retry(1)]
public  TestMethod1()

{
      //** Write test Steps
}

[TearDown]


        public void TearDown()
        {
            Drivers.TryRemove(TestContext.CurrentContext.Test.FullName, out var localDriver);
            localDriver?.Quit();


        }


}



On Tuesday, November 26, 2019 at 8:14:44 AM UTC+5:30, Oskar Berggren wrote:

Khajakhaleelulla Shaik

unread,
Nov 28, 2019, 12:38:19 PM11/28/19
to nunit-...@googlegroups.com
Hi Team,

Please find the sample code.

TestFixture]


    public class UITests : BaseClassProtractor
    {

        [SetUp]


        public void Setup()
        {
            //**Call chrome driver and open app url set up**//


   }
[Test]
[Retry(1)]
public  TestMethod1()

{
      //** Write test Steps
}

[TearDown]


        public void TearDown()
        {
            Drivers.TryRemove(TestContext.CurrentContext.Test.FullName, out var localDriver);
            localDriver?.Quit();


        }


}
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/nunit-discuss/CAHOuc7MFwxm8-txv14NrZdNVcuRmjQH28gmAFrA6x%2Bey6n7_xw%40mail.gmail.com.

Oskar Berggren

unread,
Nov 28, 2019, 12:45:23 PM11/28/19
to nunit-...@googlegroups.com
Well, what happens when you run it?

Does point 2 in the documentation apply to your situation perhaps?

Khajakhaleelulla Shaik

unread,
Nov 28, 2019, 1:45:39 PM11/28/19
to nunit-...@googlegroups.com
Hi Oskar,

Thank you so much for the support.

I have kept a assertion fail condition as well, so again test case is not getting re triggered.

Could you please let me know your available time, will schedule a meeting as well.

Regards,
Khaja Shaik

Oskar Berggren

unread,
Nov 29, 2019, 8:16:55 AM11/29/19
to nunit-...@googlegroups.com
Den tors 28 nov. 2019 kl 18:45 skrev Khajakhaleelulla Shaik <khaja...@gmail.com>:
Hi Oskar,

Thank you so much for the support.

I have kept a assertion fail condition as well, so again test case is not getting re triggered.

I don't understand exactly what you mean by that.

Run the test. Copy the output and send it please.

Anyway, I suspect the issue is that you get an exception which is NOT an NUnit assertion failure, and according to point 2 in the documentation, that aborts without running retries. It also says what to do about it.

 

Could you please let me know your available time, will schedule a meeting as well.

I'm afraid that's not quite how this works. This is a public and open discussion group and I'm just some random guy. Currently I am not able to provide paid support services for NUnit.




 

Carlos Manuel Trepeu Pupo

unread,
Jul 25, 2020, 9:17:54 AM7/25/20
to NUnit-Discuss
Hi, the reason the ReTry is not working to you it is because you need to send in the parameter the value '2'. You are sending '1' and that means run only once, NOT RERUN one.
Reply all
Reply to author
Forward
0 new messages