3 ms·
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 ne
by electrum 11y 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 https://github.com/airlift/testing-postgresql-server
2. https://github.com/opentable/otj-pg-embedded https://github.com/opentable/otj-pg-embedded
3. https://github.com/airlift/testing-mysql-server https://github.com/airlift/testing-mysql-server
- anthonybsd 11y agoHmm, I'm actually on PostgreSQL right now using H2, this might come useful. Thanks.
- electrum 11y agoJust add the Maven dependency and see their own tests for an example: https://github.com/airlift/testing-postgresql-server/blob/master/src/test/java/io/airlift/testing/postgresql/TestTestingPostgreSqlServer.java https://github.com/airlift/testing-postgresql-server/blob/ma... https://github.com/airlift/testing-mysql-server/blob/master/src/test/java/io/airlift/testing/mysql/TestTestingMySqlServer.java 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.