Creating Data-Bound Unit Tests

It is often more practical to write a single unit test and run it multiple times with different parameter values than to create many, similar tests. In fact, a tenant of good unit tests is to ensure you have covered a variety of parameter conditions. Of course, unit tests do not actually take parameters; this makes it difficult to get data into them. In this case, you need to bind your unit tests to test data. You then tell the unit test framework to run your test for each row in the test data. Of course, you can use the bound test data inside your unit test to call your code in multiple ways.

Connecting to Data

You bind a unit test to test data using the DataSource attribute class inside the unit test framework. ...

Get Microsoft® Visual Studio® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.