Hacker News new | ask | show | jobs
by lemarchr 1882 days ago
For those using Java, it's also possible to achieve this using Testcontainers[0]. It's nice to have the test DB setup co-located with your test code, and if you're using JUnit it's really easy to manage and align the DB lifecycle, e.g. fresh DB for each test, shared across class, etc.

----------

0: https://www.testcontainers.org/modules/databases

2 comments

I've been using this embedded PostgreSQL thing for tests:

https://github.com/opentable/otj-pg-embedded

It's very simple to use and works perfectly. The one problem, and it's a significant one, is that it only ships one version of PostgreSQL, and adding another was difficult enough that I didn't.

Testcontainers is also available for go

https://github.com/testcontainers/testcontainers-go