November 2011

Unit Testing Databases – Adapting the Test Data Builder Pattern for T-SQL

30 November 2011

One of the bigger obstacles to practising test-driven development, can be the perceived pain of building complex objects over and over again. This can be particulalrly frustrating when you have to construct an object with lots of attributes, most of which are irrelevant to any single test. For this reason, I am a fan of […]

Read the full article →

How to print very long strings and procedures

23 November 2011

Aaron Bertrand (blog | twitter) posted recently about the benefits of the OBJECT_DEFINITION() function when compared to INFORMATION_SCHEMA.ROUTINES when trying to search for a particular string in a very long procedure. He highights how useful the OBJECT_DEFINITION() function and sys.modules DMV are when searching for words or object references in such long SQL modules.  OBJECT_DEFINITION() […]

Read the full article →

Unit Testing Databases with tSQLt Part 5 – testing that a procedure calls another procedure

18 November 2011

In Part 4, we implemented some tests for a simple INSERT procedure with output parameters and wrote the code to pass those tests – ExceptionHandler. In Part 5 we are going to extend ExceptionHandler to collect even more information by calling another stored procedure and use our tests to make sure that ExceptionHandler calls that […]

Read the full article →

T-SQL Tuesday #024 – Exception Handling made simple

8 November 2011

I’ve been developing and using a simple logging framework for SQL Server on nearly every project I’ve worked on for the last five years, always with the intention of making it available for public use. That framework is Log4TSql and this month’s T-SQL Tuesday finally prompted me to put together a proper build on Sourceforge. […]

Read the full article →

Unit Testing Databases with tSQLt Part 4 – testing an INSERT stored procedure

2 November 2011

In Part 3, we completed the tests for the Exception table which will store SQL Server exceptions as part of the Log4TSql framework. In Part 4 we are going to put together some unit tests for the stored procedure that will populate the Exception table. The user stories we are addressing today are “As a […]

Read the full article →