Environments
SQL Server - IaaS.
TFS deployer to build and deploy the SQL files to respective database
Scenario
I have a TFS SQL Project for my database. We make the changes in TFS SQL Project and deploy these changes using the TFS build.
TFS Build generates the differential script by comparing the my database and TFS SQL Project.TFS Build generates the environment specific script.
Basically,if the objects are not present in the database but present in SQL Project then it will generate the Create statements and if the objects are present in the database but missing in SQL project then it will generate the Drop statements
Problem
I want to implement the tSQLt framework with my database.What will be the best practices we can follow by considering the above scenario?
Basically - if we create the objects in SQL project, then We will deploy these tsqlt objects till PROD. Which is not good practice?
You are correct in your belief that that you should not be deploying the tSQLt framework or associated unit tests to production.
The solution you are looking for is composite projects. Your solution presumably already has a database project with all your code - called MyDb for example. You will need to add another database project to the same solution - you could call this MyDb.tests (although the name isn't important). This second database will hold the tSQLt framework and all your tests. This is a very quick step by step:
tSQLt.RunAll
so that all your tests are run
everytime you re-bublish the MyDb.tests project.When you come to deploy to test, UAT or Production, you just build and publish from the MyDb project and none of the tSQLt framework or tests will be included.
There is a bit more to it than this - especially if you prefer to develop in SSMS then import your objects back in to Visual Studio but here are a couple of links that may help:
https://kzhendev.wordpress.com/2014/01/08/setting-up-ssdt-database-projects-and-tsqlt/