By jponczak
via codign.com
Published: Feb 13 2007 / 09:28
Code coverage is a way to measure the level of testing you've performed on your software. Gathering coverage metrics is a straightforward process: Instrument your code and run your tests against the instrumented version. Most developers understand this process and agree on its value proposition, and often target 100% coverage. Although 100% coverage is an admirable goal, 100% of the wrong type of coverage can lead to problems.
Comments
Ricky Clarkson replied ago:
I mainly use coverage to tell me what classes I'm not using - I sometimes run a coverage tool with the normal run, rather than automated tests, for this.
It's important not to be afraid of low coverage - that can just imply that the code in question changes, or changed, quite rapidly, or possibly that the code is hard to test. For example, code that instantiates a JDialog can't be run in headless mode, but it often isn't worth mocking JDialog to make it testable - the indirection hurts. Also, don't be afraid to delete tests. I deleted one today!
Voters For This Link (10)
Voters Against This Link (0)