Installing and running the example tests

First, you need to install a sample database that comes with example tests.

To install a sample database:

1. Go to Unit Test on the main menu and select Install Sample Database.

Install a sample database with examples of tests provided by tSQLt

2. Select the server to install the sample database on and specify the name of the database.

3. After the successful installation, the sample database will be added to the list of databases in Object Explorer.

View the list of databases including a sample database in Object Explorer

4. To see the list of example tests, in Object Explorer, right-click the sample database, point to Unit Test, and then click View Test List. The Test List Manager window will open.

View the list of example tests in the Test List Manager available in the SQL Server unit testing tool

5. To run an example test, in the Test List Manager window, click to place a check mark next to the required test name, right-click the test, and then select Run Checked Test(s).

Run Checked Tests

Note

In this case, Unit Test will run all tests labeled with check marks. By default, all tests are labeled with check marks. In order not to clear the checkboxes if you need to run only one or a couple of tests, you can click to select the required test, then right-click it and click Run Selected Test(s). To select several tests, hold Ctrl. When you click Run Selected Test(s), Unit Test will not run the tests labeled with check marks, but only the tests that are selected. They will be highlighted in yellow.

Alternatively, you can run an example test right from Object Explorer. Navigate to the sample database, go to the Programmability folder, and then to Stored Procedures. To run an example test, right-click the test, point to Unit Test, and select Run Test.

6. To run all tests, right-click the sample database (or the Programmability folder), point to Unit Test, and then click Run All Tests.

You can run all tests from the Test List Manager window too. Just make sure, that all tests labeled with check marks and click the Run Checked Test(s) button.