Ditch SQLite! Write Reliable EF Core Tests with Testcontainers
summary
Argues that SQLite gives false positives for production SQL engines and shows a concrete replacement: spin up Testcontainers Postgres instances in xUnit, use the implicit Ryuk reaper to auto-clean containers, and run fast state resets with Respawn. Demo covers connection-string plumbing, class/collection fixture strategies, optional reusable containers, Podman caveat, and performance: 10,000-row insert/delete runs ~1m7s on a desktop with ~3–5s container overhead. Tests pass once state bleed is fixed with Respawn.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 2:14SQLite in tests problems
- 6:09Testing with different SQL engine
- 9:43Testing database options overview
- 10:26Testcontainers and why use it
- 13:15Demo project setup
- 16:26Testcontainers in integration tests
- 19:59First test with Testcontainers
- 23:14Fixing state bleed
- 26:50Respawn for cleanup
- 33:21Improving test structure
- 37:25Performance testing with Testcontainers
- 40:38Key points recap
- 42:22Q&A
- 45:58Q&A
- 51:38Q&A
- 55:31Closing remarks
related talks
33mNo More SQLite - How to Write Tests With EF Core Using TestContainers
21mTest Containers: Where Every Test Starts Fresh
37mYes, You Can Test SQL
28mPostmortem: TDD with TestContainers
39mAndres Almiray: Setting Up Data Driven Tests
28mAdvanced Testing Techniques
59mIntegration and end-to-end testing with TestContainers and JUnit 5
26mSimplify Your Dev Life with Testcontainers
