Mar 30, 2011

Do as I say, not as I do

It has been a long time since my last post ...

As usual I have been busy taking care of my kids (if you have two kids you have an idea how much time they require :)), studying, playing with may pet projects and what not.

But something happened and motivated me to stay late and to write this post. To make a long history short, yesterday night I was working on one of my pet projects, binboo (basically a skype plugin that I and other team mates use to add/update issues on our bug tracker) and I spot some code that looked pretty useless to me.

Since I have unit tests (yeah, some of you would argue that strictly speeking they are not unit tests, but anyway, I have automated tests in place) I was not scared of changing the code, so in the next step I just removed the "dead" code running the tests after that. To my happiness, I saw only green in the unit test runner screen. 
Perfect, I though, proud of myself.
After that I just committed my changes and went (happy) to bed only to be embarrassed in our meeting today with an ugly, idiot, ridiculous bug in the exact same code I have touched yesterday. It became clear to me that my unit test coverage can be improved.

After my normal work day I just loaded the project in VS to look at the specific test case that should have failed due to my change but, to my surprise, I had no test case for this particular scenario. Hum... stupid developer.

Lesson learned, I have written a test case before reverting the changes (and of course, I'll study the code to understand why it is required after all).

Ok, let me get back to my other pet projects.

Have fun!