Shortcut: Using Database Snapshots to Provide Large Unit Testing Data with Quick Restores
SQL Server databases have a reputation for being hard to test, or at least hard to test appropriately.
For good testing, and particularly for unit tests, you really want the following:
- Database in a known state before each test
- Database containing large amounts of (preferably masked) data (production-sized)
- Quick restore after each test before the next test
For most databases, this is hard to achieve. The restore after each test means that a normal database restore can’t be used. What I often see instead, is people using transactions to try to achieve this i.e. the process becomes:
2017-12-14