Bob Crowley

Information & Communications Technology

.net .net core ASP.NET Visual Studio / .NET SQL Server Data Tools sql server Power Apps Power Automate Microsoft Teams

Portland, Maine, United States

Unit Testing T-SQL with Visual Studio SQL Server Data Tools

The Data storage and processing workload for Visual Studio includes SQL Server Data Tools which is now fairly well known as a way to develop and source-control your database. Not so well-known are the unit testing tools you get access to with this feature.

This session explores how to build unit tests against your stored procedures, functions, triggers and any other T-SQL code. The test project is a standard MS Test project, but the test building experience is much different. You'll see how to generate the project and automatically stub out the T-SQL code to test your database objects. Each of the built-in test conditions will be explained and demonstrated; they include things like validating data set checksum, scalar values, execution time, schema, row count and more. Additionally, how to create your own custom conditions in C# will be demonstrated with a real-world example.

At the end of this session you will have the knowledge to create and use SQL Unit Tests, allowing greater confidence in a traditionally untested segment of your codebase.

This is a significant re-vamp of a years-old presentation


Bob Crowley

Sr. Software Developer, .Net

Bob Crowley is a Senior Software Developer in Portland Maine where he builds solutions in the .Net and Azure ecosystems. He has been writing bugs for over 17 years, mostly in the financial industry despite (or because?) still not knowing the difference between a debit and a credit.

In his free time he likes to make the most of both weeks of Maine's summer out on the water either in a kayak or saltwater fishing.

Find Bob on twitter @contrivedex and see his occasional ramblings on contrivedexample.com.

Bob's full speaker profile