views:

77

answers:

2

I am using the provided Unit Test Engine in Visual Studio 2005 and am wondering if there is a way for me to specify the order of tests. I have numerous test classes and numerous test methods inside of each. I would like to control the order in which the test classes are executed and the order of the test methods in each.

+2  A: 

Why? Actually tests are supposed to be able to run alone. If you need to execute some particular code before running a test you should have that in your test class:

//Use TestInitialize to run code before running each test
[TestInitialize()]
public void MyTestInitialize()
{
}

//Use TestCleanup to run code after each test has run
[TestCleanup()]
public void MyTestCleanup()
{
}

I don't think the order of your test execution should matter. But if you really need to order them fellow Matthew Whited link.

Nordes
Thanks for your answer. I was trying to be lazy and piggyback my tests. I went ahead and made all my tests independent.
Mr. Will
You're welcome.
Nordes
+2  A: 

you can use Ordered Tests

http://msdn.microsoft.com/en-us/library/ms182629(VS.80).aspx

Matthew Whited