From: Michael Malone Date: 2009-04-02T13:10:25+09:00 Subject: Re: official poll - unit testing john maclean wrote: > Hello, > My name is Mr Official and I am hereby asking you to participating in > my poll. "Do you really do unit testing?" > > Acceptable answers; > > * Janet Jackme does my dishes cos I unit test all of the time > * I only unit test when < insert reason for testing> > > > In truth, I only unit test after something breaks. I guess I start doing things thinking "this will only be a one or two line change" and before I know it, I've added an extra module of code that is largely based on old code, but just different enough to break it. I also find that working in Ruby is counter-productive to working up the mental drive to unit test. This is not me getting all fanatic about ruby (ok, much) but it's true of other dynamic languages. I grew up on Java and C and with that, one tends to get bogged down in so much detail trying to translate behaviour into code, that testing is a nice, high-level view of your program that validates your design to some degree. In dynamic languages, things are already pretty high-level and the tendency here is to believe that writing code correctly every time is about as difficult as writing english sentences with correct grammar each time. A quick run through the spell checker (ruby -wc) and everything's done, right? So yes, it's probably the confidence I get from a dynamic language _after_ C and the like that lets me believe that I've become a brilliant coder overnight because I can suddenly parse strings quickly without worrying about memory leaks, pointers and NUL chars (when I was at university we had a 10% test dedicated to doing just that!). In short, the bug minefields I trained to be extra-worried about no longer exist, so setting up a Unit Test for the 'easy bits' mentally seems like more effort than it's worth. Until it breaks. Part of solving the problem is obviously defining the solution, to me, which is exactly where the test comes! It might be a slightly contradictory way of looking at things, but it's certainly honest! Michael ======================================================================= This email, including any attachments, is only for the intended addressee. It is subject to copyright, is confidential and may be the subject of legal or other privilege, none of which is waived or lost by reason of this transmission. If the receiver is not the intended addressee, please accept our apologies, notify us by return, delete all copies and perform no other act on the email. Unfortunately, we cannot warrant that the email has not been altered or corrupted during transmission. =======================================================================