Search code examples
sqlunit-testingt-sqltsqltazure-pipelines

Can you run SQL unit tests (TSQLT) during Build process in VSTS?


Is it possible to run SQL unit tests during the build process in VSTS (which would ideally cause the build to fail if any tests fail)? Or, can I only run tests after build/deploy on the drop server's SQL Server?

Thanks!


Solution

  • You need to deploy the objects under test somewhere before they can be exercised, whether this is by SQL Server Unit Tests (of the Visual Studio variety) or by tsqlt tests.

    As you point out, one possible location is after the artefacts have gone to the drop server, but there are a couple more possibilities:

    • The localdb instance provided in VSTS
    • A SQL Azure database
    • Some other database; Azure VMs, AWS, maybe even on-prem!

    Update: CLR doesn't work in SQL Azure any more, and this is required for tSQLt