Unit Testing T-SQL Code


Unit testing has become an integrated, expected part of most software development teams. Many database developers have yet to implement unit testing as a regular habit. This session will look at two-unit testing frameworks and show how to implement tests for common types of non-trivial T-SQL queries. You’ll examine the tSQLt framework as well as the Microsoft Unit Testing framework for SQL Server.

You will learn:

  • How to structure and build unit tests for database code with tSQLt
  • How to structure and build unit tests for database code with database projects
  • Understand the challenges of test data and how to solve them

Level: 200


These are the testing demos for this talk:

  • Loading and reloading test data
  • Checking standards
  • Checking joins, specifically outer join refactoring
  • Checking function calculations
  • Checking boundary conditions
  • Using the 0-1-Some pattern
  • Checking NULLs

PPTX and code on github:

Data Platform Summit – https://github.com/way0utwest/UnitTestingTSQL/tree/master

VS Live 2017 – Anaheim – https://github.com/way0utwest/UnitTestingTSQL/tree/vs2017Anaheim

About way0utwest

Editor, SQLServerCentral
This entry was posted in Presentations and tagged , . Bookmark the permalink.