Code coverage: I'm hooked (05 Nov 2015)

Over the years, I've been using code coverage tools here and there, but somehow never got addicted. In one case I remember, the tool in question simply could not cope with the codebase, making it impractical to use. In another case, code coverage results were generated as part of a Sonar build but this build ran only every few days, which meant that it never created an immediate feedback loop for me. But today, I think I finally saw the light.

In a small Java project which I inherited, I learned about the code base by bringing the code under test, i.e. by writing unit tests starting with the lower-level parts of the code and continuing on up to the its external API layers. This already was quite a fruitful exercise, as it allowed me to make changes in the code very quickly, relying on the unit tests to alert me of any breakage I caused along the way.

  • TBD: Cobertura versus Java 7
  • TBD: JaCoCo 0.75 versus Jenkins plugin

Code coverage report not working with Jenkins plugin for JaCoCo?. https://issues.jenkins-ci.org/browse/JENKINS-28652 hints that this may be due to a version mismatch between the Jenkins plugin and JaCoCo?, so I am downgrading to JaCoCo? 0.7.4 to test this hypothesis.

Using code coverage, I identified small areas in the code which had not been executed yet by unit tests. Almost each of the tests I added uncovered another corner case I had not considered yet, or which taught me something about the codebase. Examples: TBD

TBD:



When asked for a TWiki account, use your own or the default TWikiGuest account.


Revision: r1.2 - 06 Nov 2015 - 06:03 - ClausBrod
Blog > DefinePrivatePublic20151105CodeCoverage
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback