Introduction There's a lot of this that I won't have time or space to cover, so for more information, I suggest you look at Microsoft's blog on SQL Server + JSON. What I will cover is the OPENJSON table-valued function, which lets you turn JSON text into a result set, i.e. rows and columns. One … Continue reading Reading JSON in SQL Server 2016
Category: SQL Server
Dealing with transactions in tSQLt
This is the last article in a series about unit testing SQL Server with tSQLt: Introduction Anatomy of a tSQLt test Practical considerations Dealing with transactions The problem In my experience, most code is fine to be tested with tSQLt. However, code that involves transactions will get tangled up in the transaction that tSQLt uses … Continue reading Dealing with transactions in tSQLt
Practical considerations with tSQLt tests
This is the third article in a series on tSQLt: Introduction Anatomy of a test Practical considerations Dealing with transactions Getting organised One stored procedure under test is likely to need several stored procedures to test it properly. This means that the number of stored procedures in your database will increase greatly. (This is one … Continue reading Practical considerations with tSQLt tests
Anatomy of a tSQLt test
This is the second in a series of articles on tSQLt: Introduction Anatomy of a test Practical considerations Dealing with transactions Splitting into files and running tests tSQLt organises test cases into test suites. A test case is a stored procedure whose name starts with the word test. A test suite is a schema that … Continue reading Anatomy of a tSQLt test
Introduction to unit testing SQL Server stored procedures with tSQLt
This article is the first in a short series on tSQLt: Introduction Anatomy of a tSQLt test Practical considerations Dealing with transactions Introduction This is the introduction to the introduction! tSQLt lets you unit test stored procedures (including functions) on SQL Server. For why unit testing is a good idea, see my article on unit … Continue reading Introduction to unit testing SQL Server stored procedures with tSQLt
Make your test data more vicious
Imagine you have some code that works with data from a table that stores customer orders. Unfortunately your code has a bug - instead of using CustomerId for something it uses OrderId instead (both are fields on the table). What's worse, your tests pass and the test coverage looks fine. What's up? I'll assume that … Continue reading Make your test data more vicious