Share via


How to: Create a Test Project for Database Unit Testing

Before you can start to write unit tests that evaluate database objects, you must first create a test project. This project is the same test project that is available in Team Edition for Testers and Team Edition for Developers. In the case of Team Edition for Database Professionals, this project contains database unit tests, but it could contain other types of tests, too.

You can place all of your database unit tests for a given database project within a single test project. However, you might want to create additional test projects based on your answers to the following questions:

Question

Decision

Do different database unit tests need to access different database connections for test execution or test validation?

If yes, you need a new test project. Configuration of database connections is handled at the test project level.

Do you want to specify a different deployment configuration for different unit tests?

If yes, you need a new test project. Deployment configurations are specified at the test project level.

Do you want different unit tests to use different data generation plans?

If yes, you need a new test project. Data generation plans for unit tests are specified at the test project level.

For more information about each of these questions, see How to: Configure Database Unit Test Execution. As an alternative to creating a new test project to handle different data generation plans, deployment configurations, or database connections for test execution and validation, you can also provide your own DatabaseTestService implementation.

You have two options for adding a test project to a solution that contains a database project:

  • Add a test project to the solution. The test project contains a standard unit test, which you can delete. This project does not contain a database unit test class, which you must add.

  • Create a database unit test from the Test menu. When you create the unit test, Team Edition for Database Professionals also creates a test project if you request it. This project contains a database unit test class. Database test classes contain one or more unit tests.

Each approach is outlined in the following procedures.

To add a test project to an existing solution

  1. Open the solution that contains the database project that you want to test.

  2. On the File menu, point to Add, and click Project.

    The New Project dialog box appears.

  3. Under Visual Basic or Visual C#, click Test.

  4. Type the appropriate Name and Location, and then click OK.

    A test project is added to the existing solution. This project contains an Team Edition for Testers unit test, which you cannot view in the Database Unit Test Designer. Delete this test, and add a database unit test. For more information about how to add a database unit test, see How to: Create an Empty Database Unit Test.

To create a test project with a database unit test class

See Also

Concepts

Terminology Overview of Team Edition for Database Professionals