5 ms·
> I can write a test for the db logic, too. I agree but I would add that having testing niceties like branch coverage isn't really possible for SQL queries / P
by LunaSea 7y ago
> I can write a test for the db logic, too.
I agree but I would add that having testing niceties like branch coverage isn't really possible for SQL queries / PGPLSQL functions.
- pnako 7y agoBut you don't need that. That's an issue for whoever implemented your DBMS. To test your queries all you need are unit tests of the standard form: for given inputs, assert(output).
- LunaSea 7y agoI disagree. If my query calls a PGPLSQL function, I'd like to be able to test and branch cover it.
- grzm 7y agoIf you’re the one implementing the functions (or even if you’re not), there are tools such as pgtap that can help you with testing. I’ve used pgtap successful on a number of projects. There’s also no reason you can’t test the behavior of functions through a driver in some other language, though you’re now one step removed. I’m not aware of any coverage tools, though it’s been a while since I’ve looked. https://pgtap.org/ https://pgtap.org/
- GordonS 7y agoOr you could test behaviour, and not code. For example, have a test as part of your app's general test suite - insert a row, read it back and check the generated column value is what you expect.