Unit Test Your Database!

David Wheeler

From PostgreSQL Conference West Speakers

We're all used to unit testing our applications by now. The Extreme and Agile programming movements have done a great deal to promote unit testing, to the extent that many of us are now dependent on tests to assure that our applications work reliably. But how often do we test the database underlying our applications? Given that the database, as the repository for all of the knowledge and data for an application, just might be the single most important part of that application, the time for standardized database unit testing has come. This talk promotes the practice of writing and running unit tests that directly test the schema, storage, and functionality of application databases. Following a review of the available PostgreSQL unit testing frameworks, we'll review examples of testing tables, views, columns, constraints, indexes, triggers, and functions. The idea is to promote complete test coverage every aspect of a database, independent of application unit tests, to ensure reliably canonical data integrity.