Unit Testing T-SQL Code

Abstract

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

Demos

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s