ReadyRoll 1

Tutorial: Integrating tSQLt tests with Visual Studio Team Services

This tutorial describes how to run tSQLt tests as part of a Visual Studio Team Services (VSTS) deployment - it assumes you already have tSQLt tests and VSTS set up.

 If you are deploying to a Microsoft Azure SQL instance, you will not be able to use tSQLt tests.

Modify VSTS build definition

Publish test artifacts

  1. In your build definition, add a Publish Build Artifacts task.
  2. In the Path to Publish field select the path to your test artifacts (e.g. AdventureWorks.Database.Tests/bin/Release).
  3. Choose an Artifact Name and set the Artifact Type to Server.
  4. Save the build definition.

Modify VSTS release definition

Deploy tests to the target database

  1. In your release definition, add an additional Deploy ReadyRoll Database Package task.
  2. In the Package to Deploy field, select the PowerShell script created by the build (e.g. AdventureWorks.Database.Tests_DeployPackage.ps1).
  3. In Release Version, enter the release number that will be stored against deployed migrations in the [dbo].[__MigrationLog] table. For example, you could use the release id with the variable $(Release.ReleaseId).
  4. Set the Target SQL Server Instance and Target Database Name for your database.

 tSQLt requires CLRs are enabled on your server. See the tSQLt Quick Start for more information.

Run tSQLt tests on the target database

  1. In your release definition, add a Run tSQLt tests task.
  2. Choose a Test Results Output Path for the results of your test (e.g. database-test-results.xml).
  3. Set the Target SQL Server Instance and Target Database Name for your database.

Publish the test results

  1. In your release definition, add a Publish Test Results task.
  2. Select the Test result files you want to publish (this will be the same path you selected previously as the Test Results Output Path).

Your release definition will now look similar to this: 

View test results

After deploying your results, you will now see the a summary of the test results under the Environments section in the Release Summary.

You can also see more details on the Tests tab.

Didn't find what you were looking for?