title: Is there a way to calculate elapsed time for test methods ignoring time spent initializing?
body: <p>This is the kind of question that treads the gray area between StackOverflow and SuperUser. As I suspect the answer is likely to involve code-related solutions, such as creative use of <code>StopWatch</code>, I'll ask it here.</p>
  
  <p>I am using Visual Studio 2013 to perform unit testing against controllers that depend on an entity framework data model. The Test Explorer nicely presents my test results as well as their elapsed time in a short list.</p>
  
  <p>I discovered, though, that my Controller unit tests were taking considerably longer than I expected. I began to suspect this was due to the initialization code that I use to create a mocked (using Moq, but that doesn't matter) entity model.</p>
  
  <p>Sure enough, it was a small matter to show that initialization routines are included in the elapsed time.</p>
  
  <pre><code>[TestClass]
  public class InitializeTest
  {
      [TestInitialize]
      public void Initialize()
      {
          Thread.Sleep(10000);
      }
  
      [TestMethod]
      public void TestInitializeRuntime()
      {
          Assert.Inconclusive();
      }
  }
  </code></pre>
  
  <p>This produced the following output in the test explorer:</p>
  
  <p><img src="https://i.stack.imgur.com/w9JNm.png" alt="Screenshot of Test Explorer"></p>
  
  <p>This renders the elapsed time of tests backed by my mocked entity model fairly non-useful, as initialization code generally consumes greater than 95% of the elapsed time of the test. Every method looks slow, when in fact they are not so.</p>
  
  <p>Is there either an alternative configuration or some creative use of code (such as <code>StopWatch</code>, as mentioned earlier) that will allow me to report the elapsed time of test methods only, excluding time spent initializing or cleaning up the tests?</p>