Reputation: 38532
I'm in the process of writing tests for some old and disowned code. I've found coverage.py to be a useful tool in helping me decide which test to write next. As I improve our testing I'd like to see how I've affected our coverage.
Currently I'm doing this by bringing up the html report twice, in side-by-side browser windows, and visually looking for differences. This seems very crude. Do any of you have a better solution?
I found z3c.coverage, and after struggling to get zope-testrunner working with our tests, found that it only reports on regressions, not improvements. I could give the inputs as reverse, so that improvements look like regressions, but that will be quite confusing to present to others.
Upvotes: 0
Views: 1179
Reputation: 605
I was in similar situation. I wanted to see if the coverage has dropped. There was no straight forward way to get it. so, I wrote some python script and a shell script. I works fine, I have it jenkins now.
Steps
report text format:(this is default format and found it easy to parse)
Name Stmts Miss Cover
------------------------------------------------------------------------------
my/project/example.py 3 3 0%
parse report into maps where key, value is { filename : coverage_percentage }
example:
previous_run = { '/my/filename.py' : '67', '/one/more/file.py' : '89' } current_run = { '/my/filename.py' : '67', '/one/more/file.py' : '89' }
Then we can compare these maps (current_run, previous_run)
On new report generation, roll the files: Meaning, move current report file to previous ('mv report.curr report.prev') and new file to report.curr
I have put full implementation here: https://github.com/diganthdr/handytools See (coverage_compare.py)
Upvotes: 0
Reputation: 375854
Coverage.py doesn't have a diff feature. Sounds cool though, want to provide a patch? :)
Upvotes: 2