Installing tSQLt

Installing tSQLt is pretty simple, just follow this url http://tsqlt.org/download/tsqlt/ which will download tSQLt in a zip file with five files in:

1. Example.sql

The example file includes a set of sample tests, and if you want to start with a set of tests straight away, then I would install these as they give a good overview of how to use tSQLt.

2. License.txt

tSQLt is open source and licensed under the apache 2, do with that what you will :)

3. Release notes

How awesome the latest release is

4. SetClrEnabled.sql

tSQLt includes a clr assembly so you need to have clr enabled:

EXEC sp_configure 'clr enabled', 1;

It used to be that you would also have to set TRUSTWORTHY ON but this is no longer a requirement.

5. tSQLt.class.sql

This file is the actual installer for all the tSQLt objects. The install creates quite a lot of objects under the schema tSQLt - it is normally only installed on local dev databases and not production so creating these objects shouldn't worry you. If creating the tSQLt objects does worry you then I would think you are planning on installing it in the wrong place, we will cover this in a little while so don't panic just yet.

tSQLt creates lots of objects but we don't deploy them to databases we care about

Installing tSQLt

To install tSQLt all you need to do is grab either the example.sql if you want the demo tests as well or tSQLt.class.sql if you just want the framework and run that against the database where you want to deploy the tests.

If you accidentally install it somewhere you don't want it you can run the stored procedure tSQLt.Uninstall which will remove the framework and any tests.

If you do not have clr enabled then when tSQLt tries to run, the tests will fail, and so you may also check that clr is enabled on the instance using:

EXEC sp_configure 'clr enabled'

The column run_value needs to be one otherwise run the script in the SetClrEnabled.sql file to enable the clr.

Action: Create the Example database

We will use the example database to show you around tSQLt so run the Example.sql against a development instance to create the database. When it has finished, you should have a database called tSQLt_Example.