Specificity of unit testing in databases

In databases, it's uncommon to have pure functions. In most cases, the return value depends on the data in the database or, in the case of trigger functions, the function changes the data and returns nothing at all. In other words, functions in the database often produce side effects. Moreover, they are not usually idempotent, which means that when executed several times with the same parameters, they can produce different results.

Therefore, a testing framework should be able to create test data in the database, run tests, and then validate the changes in the data. Furthermore, the testing framework could also be required to manage the transactions in which the tests are executed. The easiest way ...

Get Learning PostgreSQL 11 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.