mercredi 16 septembre 2020

NUnit 3 - retry not being called on fail

I have a question about the NUnit retry attribute We are using

NUnit 3.12.0
NUnit3TestAdapter 3.17.0
C# and Selenium

This is a typical feature file

Test.feature
    Scenario Template: 01 Test footer options - Homeowner
      Given we set the destination to the homepage
      When  we select footer option "1"
      Then  we should see the url "tester" and title "test page"

This is the hook

Hooks.cs      
        [BeforeFeature(Order = 1)]
        [Test, Retry(2)]
        public static void BeforeFeatureTab(FeatureContext featureContext)
        {
            etc
        }

And here we have were the fail is being captured

        public void AssertUrlContains(string comparing, IWebDriver driver)
        {
            var currentUrl = driver.Url;
            try
            {
                WriteToReport(Status.Pass, "Pass: URL is correct");
                Assert.That(currentUrl.Contains(comparing));
            }
            catch (Exception ex)
            {
                WriteToReport(Status.Fail, "Fail error: " + ex);
                Assert.That(false);
            }
        }

Now I thought the Assert.That(false) would trigger a retry, but it is now. Can anyone see what I got wrong or missed pleased. Thanks Kev

Aucun commentaire:

Enregistrer un commentaire