Performance: Test containers for database testing
MEDIUM IMPACT
This affects the test execution speed and resource usage during database integration tests.
Use Testcontainers to start a fresh database container per test or test suite.Use an embedded or shared database instance for all tests without container isolation.
| Pattern | Test Startup Time | Resource Usage | Test Reliability | Verdict |
|---|---|---|---|---|
| Shared embedded DB | Fast (milliseconds) | Low | Low (flaky tests) | [X] Bad |
| Testcontainers per test | Slower (seconds) | Medium-High | High (isolated, stable) | [OK] Good |
| Testcontainers reused | Moderate (seconds) | Medium | High | [!] OK |