In this part of the continuous integration aka “CI” workflow, the Unit test step will be described. After the Populate step is successfully finished, where the new database test data is generated, the Test step is initiated, that will use SQL Server unit tests.
When talking about SQL Unit tests we must know that it is important to execute them in order, as part of our continuous integration and delivery sequence, to make sure that when the database is changed, its integrity, functionality or relationships will not be violated. This will allow us, upon successful results, to proceed to the next step.
It would be ideal to run these tests not only as part of a continuous delivery process but periodically on the development server itself. Once this step has been completed, it can be run independently and automatically, even outside the process of a new build.
In this workflow step, we will focus on running SQL Unit tests on the previously populated database. These unit test will be executed automatically with a script, over the newly populated database. In order to create SQL Unit tests and run them automatically, we will use ApexSQL Unit Test. This is a tool specifically designed for executing SQL Server Unit tests. As a pre-requisite, the tSQLt framework must be installed.
To walk through the instructions to create this step, see these articles:
By using ApexSQL Unit Test, we can create an easy way of performing the Test step of CI workflow, with minimal adjustments when needed.
In the next article, the final step of the CI workflow, the Sync step, will be described.
A complete SQL Server CI/CD solution
Please see the ApexSQL DevOps toolkit for a complete, end to end SQL Sever CI/CD solution including full, open source PowerShell scripts. Learn more