Hacker News new | ask | show | jobs
by moosingin3space 3336 days 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.
2 comments

Code 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.

Code 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.

Totally agreed. Branch coverage has been far more useful to me than line coverage has.
Yes, there are code coverage tools and stuff :)

This could be used, sure.