Dela via


Running Database Unit Tests

To improve and maintain the quality of your code, you can create and run database unit tests that verify the behavior of any database object and then check those tests in to version control. As you or any member of your team changes the database schema, you run both database unit tests and software unit tests to verify that the changes have not broken existing functionality. You can run individual tests, or you can run groups of tests, which are known as test lists. For more information, see Using Test Lists.

Ways to Run Database Unit Tests

You can run database unit tests in several ways that vary based on the software that you have installed, as the following table shows:

Action

Visual Studio Premium or Visual Studio Ultimate

Run tests by using the Test View window. For more information, see How to: Run Database Unit Tests and How to: Run Automated Tests from Microsoft Visual Studio.

Yes

Run tests by using the MSTest.exe command at a command prompt. For more information, see How to: Run Automated Tests from the Command Line Using MSTest.

Yes

Run tests from Solution Explorer by running a test project. For more information, see How to: Run Automated Tests from Microsoft Visual Studio.

Yes

Re-run tests from the Tests Results window. For more information, see How to: Rerun a Test.

Yes

Run individual tests or test lists from the Test List Editor window. For more information, see How to: Run Automated Tests from Microsoft Visual Studio.

Yes

Run tests as you build a project in Team Foundation Build. For more information, see How to: Configure and Run Scheduled Tests After Building Your Application.

Requires Team Foundation Server

You can run your database unit tests in a particular order by using an ordered test. For more information, see How to: Create an Ordered Test.

Interpreting Tests Results

After you run your tests, the Test Results window shows which tests have passed or failed. For more information, see Interpreting Database Unit Test Results. For more information about how to diagnose an unexpected failure, see How to: Debug Database Objects.