Reputation: 943
I have VS 2012. All tests are executed in alphabetical order. How could I enforce my own execution order of tests? I tried searching StackOverflow and google on the topic but received no results.
Upvotes: 1
Views: 80
Reputation: 2343
Basic principle of the Unit test is each test Unit is independent. And as long as you are following Arrange, Act and Assert will make your test complete. On top of that it is advised to use something called as TestIntialize in order to keep your tests clean and independent. Considering all this what your are looking for will not make your tests UNIT tests.
Upvotes: 0
Reputation: 12581
I agree with the others that the order of your tests shouldn't matter. That being said, Visual Studio doe support ordered tests. See How to: Create an Ordered Test
Upvotes: 1
Reputation: 236328
There is nice FIRST principles of writing effective unit tests:
So, if your tests depend on order they run, then your test have more than one reason to fail - they can fail if implementation does not meat requirements, OR it can fail if implementation is correct, but test has been executed in wrong order. Which makes test results uncertain.
Upvotes: 2
Reputation: 1188
As suggested by @Matt and @Pete, the unit tests should be developed in a way that they are independent of each other.
However, to answer your question, at the time of posting this answer, there isn't a way to select the sequence. Refer Visual Studio Feature Requests. It is however in their backlog.
Upvotes: 1