views:

29

answers:

3

Using Visual Studio Test Suite, is there a way to make a single unit test behave and give results as if it were several tests?

I would like to have a test for each set of input parameters I will provide. But I'd rather have all the varieties of input be data-driven, rather than having to write a seperate test for each one.

This question is similar to this one except that (1) I'm not using NUnit and (2) I might prefer my test data comes from a file (a file having data representing many tests).

+1  A: 

Have you considered putting the actual test code in a separate, private method with parameters, then create multiple test methods that each just pass different parameters into the private method?

Asserts and such will still work.

Even though it's a test assembly, you can still create whatever support classes and methods you need to support your tests.

Toby
+1  A: 

Unit tests are classes.

They can be instantiated and subclassed.

A test can (and sometimes should) have a "fixture" -- a file of source data.

S.Lott
A: 

MSTest doesn't have the RowTest as in other xUnit frameworks. However it does seem to have a feature for data-driven tests (that get their data from a DB/Xml/Csv file.) Its a case of simple things aren't possible... complex things are.

Actually this question might be a dupe of
http://stackoverflow.com/questions/2367033
http://stackoverflow.com/questions/347535

Gishu