Introducing Visual Studio Team System 2008 Database Unit Testing
Aside from adding the project to your solution, Visual Studio adds some additional solution components separate from the project (see Figure 3).
Figure 3: Additional solution components
The files control your testing experience and allow you to configure more complicated testing scenarios. Neither of these files will be part of this articles demonstration, but you can find more details in the resources at the end of the article.
The test project appears in Figure 4.
Figure 4: Sample Project components
The project is created with a default Manual Unit Test and a blank Automated C# Unit Test. These files can be deleted, but I'm leaving them in so you can see how tests are grouped and execute alongside each other later in the article. The AuthoringTests.txt file explains how to navigate the project and how to configure some of the Unit Testing options.
As you can see, I've created a Test project for Database Unit testing, but there are no Database tests in the project, so I'm going to add one and configure it to test my TSQL code.
Database Unit Test
Like all Visual Studio projects, you right-click on the project and select "Add Test" or "Add Item" to create new items in the project. The dialog below appears when you select "Add Test" (see Figure 5).
Figure 5: Add New Test
Because I'm creating the first Database Unit Test in the project, I'll be prompted to set database configuration information for the whole project. You must at least select a database connection to configure a project. As you can see in Figure 6, for simplicity, I selected the database maintained by the AdventureWorks database project. Therefore, as I change and edit the project the underlying database I'm using in the unit test will also change.
Figure 6: Set database configuration
Page 2 of 5