Code Coverage And Functional Tests
I am often asked this rather perilous question:
How do I view code coverage for my functional tests?
Short answer:
Here’s how…. However, use it only for figuring out what functionality is not covered, not as a workaround for not having enough unit and integrations.
Having to use functional tests to determine percentage of code coverage is IMO a bad smell, avoid as much as possible.
And in addition to that:
Percentage doesn’t really reflect the amount of untested/uncovered code. What are 50% in a file of 10 lines compared to 50% in a file with 1000 lines?
Gilles
26 Aug 09 at 1:06 pm
If you want code coverage you can always use the eclemma osgi hook, but I agree use it only for what is not already tested not as a percentage.
http://www.eclemma.org/devdoc/headless.html
its very easy to add when creating headless builds, and the output can be imported in the eclipse IDE
Mikkel Andersen
26 Aug 09 at 6:29 pm
Code coverage does not reflect the complexity of code. A “get my member variable” as “return m_Value;” will never break… We are using Crap4J to combine unit test coverage with code complexity. You can get an easy overview here: http://www.crap4j.org
Jan Hoppe
1 Sep 09 at 12:16 pm
@Mikkel
emma is maintained anymore ? I didn’t see any release or bugfixes after 2005. I was planning to shift to cobertura ?
Jigar Shah
30 Dec 09 at 1:17 pm