Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2010 Unit testing - rerun the same test with different parameters

I have a unit test that behaves differently depending on parameters passed. Does VS 2010 MS Testing framework have a facility to call the same test with different parameters. I am looking for something like this:

[TestRun(False)]
[TestRun(True)]
[TestMethod]
public void FooTest(bool a)
{
   RunTest(a);
}
like image 844
laconicdev Avatar asked Mar 23 '11 15:03

laconicdev


1 Answers

I have no idea why Micosoft's decided not to include this feature in their unit testing framework, whenever I search for it I find reference to the DataSource attribute that enable loading data from external resource (XML file, data base etc.)

If you do not want to use and external data source then you have two choices:

  1. Add RowTest support using MSTest extensability framework - explained here
  2. I wrote in my blog how to use PostSharp to create the external data source from the test attributes.

If you're already using VS2010 I suggest you go with the first option - there is even a full working code at Microsoft's code gallery.

like image 65
Dror Helper Avatar answered Oct 01 '22 12:10

Dror Helper