My T-SQL Tuesday contribution for this month is about unit testing database changes.
This month’s T-SQL Tuesday is hosted by Hamish Watson. You can read more about the invite by either clicking on the T-SQL Tuesday logo in this post or the link below.
If you read Hamish’s invitation in detail here he explains very clearly what unit testing is. Afterwards, he invites us all to discuss if it’s valuable for implementing with databases.
For me the answer is most definitely a yes.
In a previous post I discussed how SQL Server Professionals can benefit from using version control. Which I know a fair amount of people read. In case you missed it you can read it in detail here.
My aim in that post was to give people a gentle introduction to version control. Which you need to have a basic understand of if you want to deploy database updates in an automated fashion.
So, as far as I am concerned discussing unit testing is a natural step forward. Due to the fact that you should ideally do unit testing to check the quality of your changes way before you look to deploy these changes to production.
Recently I have been using tSQLt for unit tests which is a really popular solution for unit testing databases.
In fact, if you look online there are a lot of posts about how to use tSQLt with other applications and services. For example, Nikolai Thomassen has a useful post about how to use tSQt with SSDT and Azure DevOps. Which you can read in detail here.
Because I honestly believe automating the deployment of database changes is something most SQL Server professionals will have to learn eventually.
In fact, I believe that so much that I am looking to gain the Azure DevOps Expert Microsoft Certification.
If you’re not looking at DevOps related practices already I highly recommend you do so.
Of course, there are a lot of professionals who do this already. Which shows if you look at some of the sessions that have already been submitted for Data Community Weekender Europe here.
For full disclosure I am one of the organizers of this event. In addition, I would like to mention that other online events are also due to take place in the near future.
If you are interested in that event I also posted some updates about it over Easter here.
Anyway, I hope you enjoyed my post about unit testing database changes.
Because I’m a firm believer that unit testing will play a big role in the future for a lot of Data Platform professionals. In addition to other DevOps related practices.
Of course, I know others will have their own views about this post. With this in mind, feel free to add a comment below.
[…] If you are looking to do unit testing at the start of your pipeline I highly recommend using tSQLt. Which I talked about in a previous post here. […]
[…] In addition, you can read more about unit testing databases in a previous post I wrote here. […]