Tutorial: Integrating tSQLt tests with Visual Studio Team Services
Published 20 July 2017
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
- In your build definition, add a Publish Build Artifacts task.
- In the Path to Publish field select the path to your test artifacts (e.g. AdventureWorks.Database.Tests/bin/Release).
- Choose an Artifact Name and set the Artifact Type to Server.
- Save the build definition.
Modify VSTS release definition
Deploy tests to the target database
- In your release definition, add an additional Deploy ReadyRoll Database Package task.
- In the Package to Deploy field, select the PowerShell script created by the build (e.g. AdventureWorks.Database.Tests_DeployPackage.ps1).
- 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
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
- In your release definition, add a Run tSQLt tests task.
- Choose a Test Results Output Path for the results of your test (e.g. database-test-results.xml).
- Set the Target SQL Server Instance and Target Database Name for your database.
Publish the test results
- In your release definition, add a Publish Test Results task.
- 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.