DEV Community

Discussion on: Speed up your PostgreSQL unit tests with one weird trick!

Collapse
ayedo profile image
Alon Dolev • Edited on

I believe that one of the main problems with slow tests is not the performance of the database itself, but the time it takes to set it up for each test.

I wrote a little library to help you quickly restore a Postgres database to a 'clean' state. This way you only need to run costly database migrations once, and then you can quickly restore the database for each test.

We used it in a productive system to get a 4x speedup in our integration tests. If you're working on a JVM system it may help you too. Check it out here:

github.com/ayedo/postgres-db-restore