Tuesday, August 7, 2007

Why should you care about code coverage?

I wrote an article a few months ago about the differences between code, branch and path coverage, especially as it relates to unit testing. In my previous life, I wrote code and was a QA Manager for McCabe Software, which is where I became obsessed with metrics.

As part of any development methodology, coverage is something that project managers, developers, testers, and executives should pay attention too.

So, why should you care about coverage? My personal favorite reasons are:

1. Code coverage tells you what blocks of code have not been tested
2 Path coverage tells you what logic in your code has not been tested
3. Coverage forces you to ask more question
4. Coverage provides a way for everyone (managers, executives, developers) to talk at the same level of understanding
5. Coverage provide insight
6. Coverage help you set expectations
7. Coverage can act like documentation (well, really the tests behind the coverage, but you get my point)
8. Coverage help you prioritize
9. Coverage help you fix bugs and refactor faster

There are many studies available that talk about the benefits of coverage, as well as many open source and commercial products to help you get started. If you haven't tried measuring coverage yet, give it a shot with your next release. Measure something ... and just maybe you'll become as coverage-addicted as me.

No comments: