Here's a true story from the #python IRC channel, a frequently-asked question played out for real. I'm nedbat, the other nick has been changed to protect the innocent:

other: there's no way to automagically omit coveraging the actual test modules is there?

nedbat: you can add an omit line to the .coveragerc, but I've found useful info from coverage on my tests.

other: What kind of useful info?

nedbat: useful info: two test methods with the same name (by accident) so one was never called.

other: hah oh boy, one of the test modules I was ignoring sure enough was a test that wasn't being run :). Perhaps I better not, I hadn't thought of that before.

nedbat: yay coverage! :)

other: yay coverage!

Moral of the story: if you have enough tests to run coverage, then your tests are a serious part of your product. You should run coverage on them, it will help.

tagged: , » 1 reaction

Comments

[gravatar]
Nick Coghlan 10:44 PM on 15 Jun 2011

It's also useful for test suites that don't have automatic test discovery (e.g. Python's own regrtest): if you add a test, but forget to add the incantation to invoke it, it will show up in your test coverage data.

Add a comment:

name
email
Ignore this:
not displayed and no spam.
Leave this empty:
www
not searched.
 
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.