3 ms·
> Your CI/CD should just prep the database you need instead of mocking. This is a hard one. A lot of tests require setup steps even if you're using a real data
by jniedrauer 6y ago
> Your CI/CD should just prep the database you need instead of mocking.
This is a hard one. A lot of tests require setup steps even if you're using a real database, so it's not even that different than a mock. And if you can't give each test its own database to work with, then you have to run your tests serially. I'm working on a codebase that spins up 4 separate database engines in docker, and each test has quite a few setup steps. The result is brittle tests that take hours to run, so they're not very useful as a release gate. I've been bitten by mocks before too though, so I don't have good answers.
- sedatk 6y agoWe did that with transactions. Every test gets their own view of the database, and rolls its changes back after they're done. They take much longer than unit tests but it's worth it in the end as writing unit tests are easy, there is no need to create mocks, and you also test if your DB queries work too this way.