Introduction If you hang around programmers for long enough, you might hear people use terms like complexity or Big O notation, or say that performance is of the order … such as of the order N squared. I hope that this article makes those terms a bit less confusing. The basic idea is seeing how … Continue reading Complexity: Performance trends in code
Category: Database
Unit testing database queries
In this post I will try to describe an approach to unit testing database queries. It happened to be inspired by some testing I was doing of some C# code, but you could apply the same ideas to other languages. Note that if you’re unit testing stored procedures then I recommend using something like tSQLt, … Continue reading Unit testing database queries
An introduction to Entity Framework
Introduction This is article isn’t a hands-on guide to getting started with Entity Framework (EF). Instead it aims to give you an understanding of what EF is, whether it’s for you, and if so, which of its options apply best to you. In the next article I will do the hands-on stuff, where I walk … Continue reading An introduction to Entity Framework
Named parameters with default values can help unit tests
Introduction I find myself using default values much more in unit tests than in production code. That is, I do it more often, and use more parameters with defaults per method. This isn't because default values are bad, but they are often particularly useful when setting data up for unit tests. It makes the tests … Continue reading Named parameters with default values can help unit tests
Automated testing of a website: Dealing with the database
This article proposes an approach to handling the fine-grained parts of the database parts of an automated system test of something like a website. You would need other things for the remaining jobs: To orchestrate the test, something like SpecFlow; To interact with the website, something like Selenium; To do the bulk updates to the … Continue reading Automated testing of a website: Dealing with the database
Reading JSON in SQL Server 2016
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
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