Hacker News new | ask | show | jobs
by electrum 3971 days ago
Aside from a few seconds to spin up a new PostgreSQL instance, it should not be any slower than SQLite. We have a wrapper [1] (forked from [2]) that starts a new PostgreSQL instance from Java unit tests. We have the same for MySQL [3]. This allows every developer to automatically run tests against the target database without needing to set anything up.

(The common alternative in Java is to use H2 or Derby, which are similar in concept to SQLite)

1. https://github.com/airlift/testing-postgresql-server

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

3. https://github.com/airlift/testing-mysql-server

1 comments

Hmm, I'm actually on PostgreSQL right now using H2, this might come useful. Thanks.
Just add the Maven dependency and see their own tests for an example:

https://github.com/airlift/testing-postgresql-server/blob/ma...

https://github.com/airlift/testing-mysql-server/blob/master/...

Though you want to use @BeforeClass / @AfterClass or similar rather than creating one for each test.