The Light The Light - 3 months ago 46
C# Question

How to run a test method with multiple parameters in MSTest?

NUnit has a feature called Values, like below:

public void MyTest(
[Values(1,2,3)] int x,
[Values("A","B")] string s)
// ...

This means that the test method will run 6 times:

MyTest(1, "A")
MyTest(1, "B")
MyTest(2, "A")
MyTest(2, "B")
MyTest(3, "A")
MyTest(3, "B")

We're using MSTest now, is there any equivalent for this so that I can run the same test with multiple parameters?

public void Mytest()
// ...


It is unfortunately not supported in MSTest. Apparently there is an extensibility model and you can implement it yourself. Another option would be to use data-driven tests.

My personal opinion would be to just stick with NUnit though...

EDIT: As of Visual Studio 2012, update 1, MSTest has a similar feature. See @McAden's answer below.