|
|
|
|
|
by donjoe
528 days ago
|
|
testcontainers is great. I struggled a bit with testcontainers due to the nature of one container per test which just felt too slow for writing gray/blackbox tests. The startup time for postgres was > 10 seconds. After a bit of experimenting, I am now quite happy with my configuration which allows me to have a snappy, almost instant testing experience. My current setup: - generate a new psql testcontainer _or_ reuse an existing one by using a fixed name for the container
- connect to the psql container with no database selected
- create a new database using a random database name
- connect to the randomly generated database
- initialize the project's tables
- run a test
- drop the database
- keep the testcontainer up and running and reuse with next test With this setup, most tests run sub-second; |
|