Chapter 27. Writing unit tests for Transact-SQL

Luciano Moreira

Unit testing is a known methodology among developers around the world, be they Java, C#, VB.NET, or C++ programmers. Unit testing helps you produce code with fewer bugs and achieve a higher degree of quality. Although this has become a well-known practice, when it comes to databases, we haven’t seen the same adoption rate.

The objective of this chapter is to introduce some basic concepts of unit testing that you can apply when programming with T-SQL, without using any third-party tool or external framework. I’ll show you how to make the necessary adjustments and bend some rules to adapt unit tests to databases.

Unit test basics

The primary goal of unit testing is to take the ...

Get SQL Server MVP Deep Dives, Volume 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.