r/softwaretesting • u/ajmalhinas • Jul 07 '26
Do you verify database tables after automated test sessions? What tools and process you use?
We think comparing the resulting database tables of an automation session against an expected database state can provide several advantages: detecting data integrity issues that may not be visible through UI or API assertions, identifying unintended side effects across tables, and catching defects closer to the point where they are introduced.
Before implementing this more systematically, I’m interested in understanding how this works in real-world QA teams.
Do you currently perform this kind of database-level verification after automated test runs? If so, what tools or approaches do you use to compare the actual database state against the expected state?
More importantly, has this practice genuinely helped your team detect defects earlier or reduce debugging time? Or did the maintenance of expected datasets and database comparisons create more overhead than value?
2
u/n134177 Jul 08 '26
I've had to create a PostgREST container that would query the database independently, with no logic or code shared with the API, to verify that what the API was outputting was consistent with what was in the database.
Yes, in automated testing.
Yes, it caught a whole bunch of defects.
Now, that is a very costly test. However, we were dealing with values that HAD TO be correct due to liability. These test cases provided evidence and documented the defects that, then, got fixed. The tests remain in place to ensure a regression won't happen.
Anyone who outright dismisses the idea is either lying or not a good QA.
2
u/MudMassive2861 Jul 07 '26
Mostly avoid DB check as most GET api can give the required details. But if you don't have GET which give details you need to. U may need to add a DB wrapper depends on DB u using. In my last job we where checking even message queue data using subscribers in service bus. So ya depends on your requirements you can add those.
3
u/jrwolf08 Jul 07 '26
It depends on the project. I am currently doing database validations on both my main products, but they are special cases. One is entirely backend, so a POST kicks off a bunch of processes that write to the database. Other is UI that has a non standard GET functionality it returns the merge of all previous POST/PATCH changes. So I do need to keep track of the database.
My code sits in the same repo as the product code, so I just import the data access layer functions when I need them.
2
u/CertainDeath777 Jul 07 '26
For a bank it is necessary. But i probably would not compare whole tables like you suggested, but some strategic values, as comparing whole tables for many test runs will put heavy strain on infrastructure and runtimes.
Except if you do testing with isolated almost empty db, but essentially you dont want to run mocks for this type of testing.
0
u/ASTRO99 Jul 07 '26
Not really sure why would you want to do DB checks on properly setup application. Only things that comes to mind, we had a DB triggers in my previous job that migrated incoming data partially to another table so they can be used by another legacy app.
But other than that, it's just one check during development that everything is setup OK. migration scripts are working and then you never have to see DB again unless you are manipulating data.
0
u/Useful_Calendar_6274 Jul 07 '26
Testing database values is something from the era of monoliths really. I don't think you see it much at all these days
0
u/dukko18 Jul 07 '26
I built an open source testing tool called Dokkimi that will let you do this. Feel free to check it out dokkimi.com/docs. At the very least I could use the feedback on why it may or may not be helpful to solving this usecase.
0
u/latnGemin616 Jul 07 '26 edited Jul 07 '26
The day I learned how to test APIs was the day I stopped needing SQL for anything.
This is not a thing. If the database consumes data from a form, you can test the form. If the data outputs to a UI page, you can test the API endpoints. If using a microservice a Dev can mock the data and check for expected output. QA should just run UI and API checks.
The fact companies want you to test the DB is absurd.