Before you can create and run tests on a database, you need to add the database to SQL Test.
Adding a database to SQL Test
In the SQL Test tab, click :
The Add database to SQL Test dialog box opens:
Select the database you want to run tests on, and click Add Database.
The Install tSQLt Framework dialog box opens.
When you add a database, SQL Test will:
- Install the tSQLt framework on the database
Installing the framework adds a number of stored procedures, functions and a SQL CLR object to the database. You use the framework to implement unit tests in T-SQL.
For more information about the objects in the framework, see tSQLt User Guide.
- If using V1.7.3 or earlier, or a SQL 2017 or later database, Set TRUSTWORTHY ON for the database. If using V1.7.4 or later, this setting is no longer a requirement on pre-SQL 2017 databases due to an upgrade of the tSQLt framework to V1.0.5873.27393.
- Enable SQL CLR for the server
- If you want to add a number of tests you can run to detect issues with your database, make sure the Add SQL Cop static analysis tests check box is selected.
For more information, see SQL Cop static analysis tests.
Click OK.A progress dialog box opens.
- On the progress dialog box, click OK.
The database is added to SQL Test.
Removing a database from SQL Test
The SQL Test interface lists all connected databases with the tSQLt framework installed.
To remove a database from SQL Test, uninstall the tSQLt framework from the database. To do this, in the SQL Test tab, right-click the database you want to remove, and click Uninstall tSQLt Framework:
Uninstalling the framework removes the tSQLt stored procedures, functions and CLR object from the database. The tests you've created on the database aren't removed.