Sometimes it is maybe necessary to bring some order into your unit tests in Visual Studio. Indeed, this is not really the idea of unit testing, however it might be necessary for a variety of reasons. Facing this issue, I had to search the MSDN documentation for a while.
I was desperately looking for some syntax like:
[TestMethod(Order = 1)]
However, the only way to bring some order in your tests is, by creating some ordered tests in addition to your unit tests.
To do so, you first create a set of unit tests. In my case, some of the tests should be only executed after other run successfully. Otherwise the result might look like:
Now we create a new test project called Order Test:
When opening the project you actually can arrange the order of the previously written unit tests:
Running the test then is possible by selecting the test from the Test View window. Your tests will actually only appear as one entry in the list but you will see that all the selected tests run successfully – in the correct order.
Paul
GR