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)
29 May 2015

Starting a New Project Naively Sure is Easier

Experience is not always an advantage

Starting a new pyramid fun project with some friends here. Sometimes I think that having experience with another pyramid project isn't always helpful. Instead of just writing my simple objects and growing them, I'm thinking: "well, for this kind of thing, we added xy and yz, and we made a feature to ..." and then instead of coding along, I'm sitting there, thinking if adding that feature right away makes sense, and if I should copy that bit of code or not.

Sure I could start with the simpler objects, but then I'd have to migrate them later on. On the other hand, if I try to do it all at once now, I can just sit there with a cup of tea for a couple of days and try to "waterfall" it all through. Have to find some middle ground somewhere, and have to accept that at least initially "migration" will be to the tune of "throw away your database and start over". Gotta get moving.


Posted by betabug at 18:04 | Comments (0) | Trackbacks (0)