betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

07 May 2015

Catching up with coverage... and finding some bugs

Bebu looking at things

Yesterday I noticed again that on one of my projects the test coverage is slipping. Now test coverage isn't everything, and hey, we're not that bad since lots of projects have no tests at all... but still I'd prefer the coverage to be at 100%. So in a moment of not wanting to touch any new tasks ("just give me something small to hax0r, a few lines"), I looked at the coverage report, trying to fill a few small holes.

A few of those small one or two line holes were quickly filled. A one line function without a test? Tchak, done! Some others were more mysterious. And then there was one that should have been easy to plug, but it evaded me. An if x not in some_list that should raise an exception was not covered. But once I wrote a test with assertRaises, that part of the code was not reached any more. You start to test for something and then it disappears? That would be a new one.

It took me some gazing at the code to discover that a (hidden) similar check a few lines above was already raising the exception. So that part of the code was essentially duplicated and useless. That's the morale of the story: Bringing the test coverage back to 100% might not make your code foolproof, but sometimes it just makes you look at the code again and spot a bug here and there.


Posted by betabug at 12:11 | Comments (0) | Trackbacks (0)
ch athens
Life in Athens (Greece) for a foreigner from the other side of the mountains. And with an interest in digital life and the feeling of change in a big city. Multilingual English - German - Greek.
Main blog page
Recent Entries
Best of
Some of the most sought after posts, judging from access logs and search engine queries.

Apple & Macintosh:
Security & Privacy:
Misc technical:
Athens for tourists and visitors:
Life in general:
<< First Swim of the Season | Main | 520... Quality of Life >>
Comments
There are no comments.
Trackbacks
You can trackback to: http://betabug.ch/blogs/ch-athens/1376/tbping
There are no trackbacks.
Leave a comment