This is something that is puzzling me a bit.
I am seeing some people who like to implement DB-related integration tests (in the case of BLOBAs) to test the insertion with a Legacy DB in a CI pipeline, which I think bring very little value (while they require a fair amount of time for implementation) and bring a fair amount of risks, here is below my rationale:
- The premise of the folks implementing those tests: I wanna test that my data are properly inserted into a certain DB, which often translates to: I want to check that the DB set of tables or whatever constraints are ok when I'm executing that piece of DB-related code or containing the aforementioned piece of DB-related code.
- Against which DB (ie. which env) are you running your int. tests?
- Only dev: you're testing the testing DB constraints, any relevance to the actual prod. operations? Clear benefits?
- Prod: existing data might mess up with your test, also, you test might mess up with the business (risky, especially if the only safeguard, aka your non0completing transaction happens to complete in prod env)
- Everything in between (eg. staging): then it really depends if the staging schema is up-to-date... it's not always the case...
- When are you running your tests: before or after DB migration? More often than not, it seems that they're run before the migration in a given env, risky too. So now you have to differentiate integration tests that must be run before or after DB migrations (adding a bit more complexity which is not taken of atm). In the case that these integration tests are failing while being run after the DB migration is done, do you want to revert the DB migration?
I'm wondering if I am missing anything, or if I am wrong about something in particular? Basically since the premise is those tests are actually relevant because they're testing the DB schema, and maybe not even the one that is gonna be used in prod.
Put it otherwise, when are DB-related integration tests relevant when being run in a CI pipeline?
Note, my post differs from:
- Are (database) integration tests bad? and the best upvoted answer: https://softwareengineering.stackexchange.com/a/301508/171752
- Should integration test be included in continuous integration (CI)?
It's more a combination of both.