Run database unit tests

The guide explains how to run unit tests against a database and manage test results using the Test Results window.

To run unit tests, in Database Explorer, right-click the required database and select Unit Test > Run All Tests.

The Test Results window opens and displays detailed information about each executed test. It shows which tests passed or failed and includes error details for failed tests.

Test Results window

The grid consists of the following columns:

  • Status – Indicates whether the test passed or failed.
  • Test Name – Displays the name of the executed test.
  • Class Name – Displays the test class in which the test is defined.
  • Error Message – Displays details for the test that failed.
  • Execution Time – Displays time taken to execute the test, shown in milliseconds (ms).

Top toolbar

The following table lists the top toolbar options.

Icon Name Description
Run Checked Test(s) Run Checked Test(s) Executes all tests that have their checkboxes selected.
Shortcut: Ctrl+R
Run All Tests Run All Tests Re-runs all tests.
Stop Tests Stop Tests Stops the current test run.

Test Results grid

On the grid, you can select or clear the checkboxes next to the tests you want to re-run.

Right-click the grid to access the following options.

Name Description
Run Selected Test(s) Runs the tests highlighted in the grid.
Open Test Opens the test in SQL Editor.
Run Checked Test(s) Executes all tests that have their checkboxes selected.
Shortcut: Ctrl+R

Status bar

The table displays information about the test run.

Name Description
Failed: [N] Number of tests failed.
Passed: [N] Number of tests passed successfully.
Total: [N] Total number of tests executed.
Checked: [N] Number of test classes or tests with selected checkboxes.
Connection: ‘server_name’ Name of the current SQL Server connection.
Status: [connection_status] Current status of the server connection.
Database: [database_name] Name of the database against which tests were executed.