Creating new SQL unit tests through tSQLt

To add a new test

1. In Object Explorer, right-click a database or a specific database object you want to create a test for, point to Unit Test, and then click Add New Test.

Alternatively, go to Unit Test in the main menu and select Add New Test.

2. The Add New Test dialog window opens.

Specify test details in the Add New Test window

3. Specify a connection and database for the test to be created on.

4. In the Test Name box, specify a name for the new test.

Note

If you want to create a new test with a name that already exists, Unit Test displays the Test creation failed warning message informing that there is already an object with such a name in the database.

5. In the Class Name box, specify a class, to which the new test will be added.

Note

A test class is a special schema configured to include one or more related tests.

6. Click Add Test.

7. The test has been created, and Unit Test opens the ALTER PROCEDURE query template for it.

View the query template of the SQL database unit test

Note

To learn how to write tests in T-SQL using the tSQLt framework, see tSQLt User Guide.

Add a new test from the Test List Manager

  1. Right-click the sample database or test class and click Add New Test.

Add a new test from the Test List Manager available in the SQL unit testing tool

2. The Add New Test dialog window opens. Follow the steps described above.

Note

To learn more about Test List Manager, see the Viewing test list topic.