title: Controlling execution order of unit tests in Visual Studio
body: <p>Okay, I'm done searching for good information on this.
  I have a series of Unit Tests that call a static class which, once initialized, sets properties that cannot (or I don't wish to) change.</p>
  
  <p>My problem is I cannot enforce a set order for the tests to run. If I could, I could run them in such a way as the static properties would be set in a reliable way, and I could Assert on them, but unfortunately the Microsoft.VisualStudio.TestTools.UnitTesting framework just runs them in a seemingly random order.</p>
  
  <p>So, I found this <a href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.priorityattribute.aspx">http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.priorityattribute.aspx</a> which says in the Remarks section "This attribute is not used by the test system. It is provided to the user for custom purposes." Huh? What good is it then? Do they expect me to write my own testing wrapper to take advantage of this fabulous attribute (of which I could easily write myself if I wanted to go to that level of effort...)</p>
  
  <p>So, enough of the rant; Bottom line, is there a way to control the order my unit tests run? </p>
  
  <pre><code>[TestMethod]
  [Priority(0)]
  </code></pre>
  
  <p>etc. does NOT seem to work, which makes sense, since Microsoft says it won't.</p>
  
  <p>Also, please no comments about "violating isolation". The TestClass isolates what I am testing, not the individual TestMethods. Regardless, each test can be run independently just fine, they just can't be run together in a random order as there is no way to tear down the static class.</p>
  
  <p>Oh, I also know about "Ordered Test".</p>