We are using PostgreSQL along with EAR deployed to JBoss. During the build process we have a development database dump that is used then in integration test: special artifact is deployed and tests communicate with the app using http client.
Currently, the database state changes during tests run, so we have no way but to put additional content for each test that modifies it, so no tests would depend each other. It takes really lots of time and patience as such test become even dependent on the order of records.
Is there a way to make a snapshot of DB so that to restore it after each test run with a reasonable amount of resources? Could Docker help? Or any other way around?
H2 is not the way, because we use some PostgreSQL-specific features. Tests may span multiple transactions, so I guess rollback would not help either.
One straightforward way with Docker is to have your database snapshot as a volume you reset and then mount into the beginning of your test run.
You can massage this data prior to your tests running (either have a tar of your entire starting database config or something else), then launch your PostgreSQL test database, with the test data mounted as a volume and your PostgreSQL pointing to this, for each test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With