1

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).

Community
  • 1
  • 1
Brent Arias
  • 29,277
  • 40
  • 133
  • 234
  • possible duplicate of [How to RowTest with MSTest ?](http://stackoverflow.com/questions/347535/how-to-rowtest-with-mstest) – Gishu Jun 22 '10 at 03:20

3 Answers3

1

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
  • 7,354
  • 3
  • 25
  • 26
1

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
  • 384,516
  • 81
  • 508
  • 779
1

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
MSTest Equivalent for NUnit's Parameterized Tests?
How to RowTest with MSTest?

Community
  • 1
  • 1
Gishu
  • 134,492
  • 47
  • 225
  • 308