I have been using tSQLt to do unit testing within SQL Server for the last 2 years. I already did a presentation twice at work and decided to document some of this so that it might help other people looking at using tSQLt to do unit testing with SQL Server.
This will be a multi part series, some of the stuff I will cover:
What is unit testing and why you should be unit testing
What tSQLt is and how to get started
Sample of all the different functionality that tSQLt provides
How to integrate tSQLt within your builds
Before starting, let me first tell you what happens when something is checked in into out source code repository.
1) The applications are build
2) Integration tests are run
3) Unit tests are run
4 If there were any errors an email is sent to the developers with the output of the failed tests or compilation errors
If there are errors, tSQLt will give you the name and the error for each test as well have a summary which looks something like the following
---------------------------------------------------------------------------------
Test Case Summary: 128 test case(s) executed, 127 succeeded, 1 failed, 0 errored.
---------------------------------------------------------------------------------
Before explaining what unit tests are, let take a look at what the cost is of fixing a bug
Take a look at this image below from a presentation by Stefan Priebsch, it shows you what the cost is of fixing a bug within the software lifecycle
As you can see, the relative cost fixing a bug is 150 times compared to if it was fixed during the requirements stage.
When doing unit testing, you hopefully will catch the errors before it gets to the point where the cost to fix the bug is 20x or higher.
In the next post I will explain what unit tests are and what they will provide to you and your team
No comments:
Post a Comment