title: Retry a Visual Studio C# TestMethod
body: <p>I'm curious to know if there's any built-in mechanism to <strong>retry</strong> tests in the Visual Studio 2008 unit testing framework for C#.
  Case in point, I have a C# unit test which looks something like:</p>
  
  <pre><code>[TestMethod]
  public void MyMethod() {
      DoSomething();
      Assert.Something();
  }
  </code></pre>
  
  <p>Now, occasionally <code>DoSomething()</code> performs badly; in that case I would like to rerun the <code>DoSomething()</code> method before reaching the assertion. Obviously I can do something like:</p>
  
  <pre><code>...
  do {
      Initialization();
      DoSomething();
  } while (PerformedOK() == false);
  Assert.Something();
  ...
  </code></pre>
  
  <p>Though this is a bit cumbersome because of the added loop and repeating the test initialization which would otherwise be completely handled by other methods / class constructor.</p>
  
  <p>My question is whether there is a more convenient mechanism for retrying a test, something like:</p>
  
  <pre><code>DoSomething();
  if (PerformedOK() == false) Retry();
  else Assert.Something();
  </code></pre>
  
  <p>which will automatically retry the test <em>without</em> registering it as a failure, while performing all the regular initialization code as usual.</p>