Data-driven Unit Testing

The [DataSource] attribute enables you to specify a data source from which to pull test data. The values from this data source are automatically available from a shared test context object. As shown in Figure 1, you can replace hard-coded values for your parameters with ones pulled from your test database. Visual Studio Team System recognizes the presence of a data-driven unit test, and will execute the unit test once for each row of data available from the data source.