Chapter 25Database Patterns

Patterns in This Chapter

Database Sandbox 650

Stored Procedure Test 654

Table Truncation Teardown 661

Transaction Rollback Teardown 668

Database Sandbox

How do we develop and test software that depends on a database?

We provide a separate test database for each developer or tester.


Many applications use a database to store the persistent state of the application. At least some of the tests for such an application will require accessing the database. Unfortunately, a database is a primary cause of Erratic Tests (page 228) due to the fact that data may persist between tests. A major goal in keeping tests from interacting ...

Get xUnit Test Patterns: Refactoring Test Code now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.