Brent Arias
Brent Arias

Reputation: 30215

Making One Unit Test Count as Several

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

Upvotes: 1

Views: 160

Answers (3)

Gishu
Gishu

Reputation: 136683

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?

Upvotes: 1

S.Lott
S.Lott

Reputation: 392050

Unit tests are classes.

They can be instantiated and subclassed.

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

Upvotes: 1

Toby
Toby

Reputation: 7554

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.

Upvotes: 1

Related Questions