3 ms·
I realize that statically checking for tests is reducible to the halting problem, but would it be possible to have some sort of code-coverage checker that would
by moosingin3space 9y ago
I realize that statically checking for tests is reducible to the halting problem, but would it be possible to have some sort of code-coverage checker that would make sure all externally-facing functions have non-zero coverage? That could be used to construct a checklist for a library developer.
- kilotaras 9y agoCode coverage in itself isn't a very useful metric. Classic example is big test with no asserts will get you pretty good coverage. There's a rather computationally intensive technique called mutation testing where you introduce bugs into code (e.g. change + to -, flip conditionals, etc.) and check that tests fail.
- burntsushi 9y agoCode coverage has been useful to me in practice, so I think blanket statements like "code coverage isn't useful" is very misleading. For example, code coverage has helped me identify specific branches in my code that are untested, which in turn help guide me to write additional unit tests. You don't need to completely dismiss other testing techniques. Mutation testing can be useful at the same time that code coverage is useful.
- yazaddaruvala 9y agoTotally agreed. Branch coverage has been far more useful to me than line coverage has.
- Manishearth 9y agoYes, there are code coverage tools and stuff :) This could be used, sure.