views:

42

answers:

1

I have a set of Selenium/MbUnit Tests that work fine, but tend to take a while to run (over 4 hours) A problem i am finding is that about 1 in 20 test seems to timeout when running. I have confirmed the Selenium GRID is working and the Selenium RC's are all fine, it just seems to be a qwerk of the system. What is really annoying though is that if i run these tests again they will usually pass.

What i want to know is if there is a way for me to auto rerun the tests (probably in the code) if a perticular type of exception is caught...

I have attempted to put a few lines of code in the catch statement but i know this is a very hacky way of re running the tests. Here is the code:

 catch (AssertionException e)
            {
                if (e.Message() == "TimeOut") //Something similar to this
                {
                      this.Test();
                }
                else
                {
                     verificationErrors.AppendLine(browserList[i] + " :: " + e.Message);
                }
            }

Any suggestions?

+1  A: 

It's probably not a real answer to your question, but since the problem is related to a timeout issue occurring while running the tests, have you tried to change the default timeout value (of 10 minutes I believe) by using TimeoutAttribute?

[TestFixture, Timeout(3600)] // Use 1 hour instead.
public class MyTestFixture
{
    // ...
}
Yann Trevin