O'Reilly logo

Microsoft® Visual Studio® 2010 Unleashed by Lars Powers, Mike Snell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required