Share via


Troubleshooting Database Unit Testing Issues

You might encounter the issues in this topic when you perform unit tests on a database.

Data Generation, Unit Tests, and Permissions

You can configure a unit test to automatically deploy the database and generate data. If you lack sufficient permissions to generate data to the target database, you might receive an error that indicates only that you lack permissions to connect to the database.

Note

To work around this issue, run the data generation plan manually. If you lack sufficient permissions to generate data, this approach will give you a more detailed error message that helps you to correct the problem.

Performing Unit Tests on Numbered Stored Procedures

If you create database unit tests for a database that contains numbered stored procedures (such as MyProcedure;2), the Create Unit Tests dialog box does not display the number designation. This behavior could result in the same procedure name appearing multiple times if you have multiple numbered versions of one or more stored procedures.

In addition, the script that is generated to test those stored procedures is missing the number designation. For example, if you generate a unit test for a procedure that is named MyProcedure;2, the script resembles the following:

EXEC @RC = [dbo].[MyProcedure]

Note

To work around this issue, modify the generated script to add back in the number designation before you run your unit tests. If you generated unit tests for multiple numbered stored procedures, you will need to correct each test.

Unit Testing and App.Config Changes

If you modify the App.Config file in the test project, you must rebuild the test project before those changes will take effect. These changes include those that you make to App.Config by using the Project Configuration dialog box. If you do not rebuild the test project, the changes are not applied when you run the unit tests.

Database Deployment in Unit Tests

If you deploy a database when you perform unit tests, the database is created by using the connection string information that is specified in your unit test configuration. The connection information that is specified in the database project build properties is not used for this task, so you can run different unit tests against different instances of the same database.

See Also

Tasks

How to: Configure Database Unit Test Execution

Concepts

Terminology Overview of Team Edition for Database Professionals

Other Resources

How to: Create Database Unit Tests for Functions, Triggers, and Stored Procedures