57.4. Database Unit Testing

You already looked at unit testing in Chapter 20; this section expands the topic to databases. This kind of test is useful to verify the functionality and design of your schema objects and can work hand-in-hand with your Data Generation Plans and Schema Database Projects. To create a new Database Unit Test, from the Tests menu select New Test and choose the template for Database Unit Test, then create a new project if needed. For the first DB Unit Test in the project you will be prompted for a database to run the tests against. You can change this later from the Database Test Configuration option under the Test menu. It's highly recommended to have a dedicated database for test purposes for each developer. You can also select to deploy the project before running the tests. This will guarantee you are always running the tests against the latest version of the schema. Finally, you can select to use a Data Generation Plan to re-create the data for the unit tests.

To create and edit the tests you have a designer (Figure 57-5). From there you can select the different test methods or create new ones and add new test conditions. The conditions available are Empty ResultSet, Execution Time, Inconclusive, Not Empty ResultSet, Row Count, and Scalar Value. When selected, you can configure them from the properties windows — for example, to set the value for the row count. You can also create your own test conditions. The Power Tools (explained at the end of the ...

Get Professional Visual Studio® 2008 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.