[TIP] Reporting coverage for changed lines of code
marius at gedmin.as
Thu Apr 26 15:57:53 PDT 2012
On Wed, Apr 25, 2012 at 07:00:53PM +0200, Frank Niessink wrote:
> I was doing some refactoring in a code base with reasonable but not
> perfect unit test coverage. While reviewing my changes I was
> wondering: of the lines changed, which ones are not covered by unit
> tests? If I had a report showing just that, I could make sure that
> whenever I commit a change, the unit test coverage for the changed
> lines would be 100%. Thus continuously improving overall coverage and
> reducing the risk of changes at the same time. Wouldn't that be neat?
I've setup my buildbot to send nagging emails whenever the number of
uncovered lines increases in any source file. It uses the coveragediff
script from http://pypi.python.org/pypi/z3c.coverage, and it works
with the standard trace.py-style annotations, although I would very much
like to find the time to make it understand coverage.py natively.
I don't get indication *which* uncovered lines were touched by the
recent change, although that should be computable given a unified diff
and both coverages. Just a simple matter of programming ;)
I never bothered because:
(1) I thought that maybe seeing all untested lines will prompt people
to fix them all, instead of fixing just the newly introduced
(2) I'm lazy
> This started out as conversation on twitter (see
> https://twitter.com/#!/fniessink/status/195166296848072704) with Ned
> Batchelder because I was thinking that this would be an excellent
> feature for coverage.py . What do you guys think?
I like it. The trick is finding or convincing someone to actually do
the work. ;)
Some people have told me they don't think a fat penguin really embodies the
grace of Linux, which just tells me they have never seen a angry penguin
charging at them in excess of 100mph. They'd be a lot more careful about what
they say if they had.
-- Linus Torvalds, announcing Linux v2.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: Digital signature
More information about the testing-in-python