Note that there are some explanatory texts on larger screens.

plurals
  1. POControlling execution order of unit tests in Visual Studio
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload