Summary of Database Unit testing techniques

In a previous blog, I described some of the techniques I have been using to do unit testing with database connected code. This article is my summary of the techniques I have run across and will hopefully be updated over time. This list is ordered somewhat by test speed criteria. It is my opinion that working with a test database is probably the more desirable option for testing. This approach is really more of a system test with all of its benefits, such as exercising more code automatically, and it’s drawbacks. The drawback is mostly the problem of returning the database to a known state before each test. Failure to do that makes you spend lots of time tracking down false alarms. The rollback technique mentioned below is the most reliable way to accomplish that goal, but like it’s heavyweight cousins, it is a very slow technique, particularly if you do reads and multiple updates within the same test. Even worse,

Advertisements

Comments are closed.