2

I am using Timeout attribute for nunit test case as below:

[Test, TestCaseSource("TestCases"), Retry(2), Timeout(10000)
public void test(){
    // Some code that runs for more than 10 seconds
}

I have gone through the documentation of nunit but it said that apart from assertion error, retry will not work but I have a situation where test times out.

I want this test to execute again as it is timing out but it executes only once using above code. Please help.

2
  • Let's get this person some help!
    – Brian
    Commented Mar 1, 2019 at 20:54
  • Thanks but no answer yet :(
    – Ayush Goel
    Commented Mar 6, 2019 at 5:53

1 Answer 1

2

Retry only works on Assertion failures. You will have to write a custom Retry attribute that retries on Errors as well. Here is one way of doing it: https://stackoverflow.com/questions/46319701/nunit-retry-on-exception-by-default

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.