|
Write a bloody test!
[
kevin
]
I once heard that insanity was doing the same thing over and over and expecting a different result. I have recently encountered an example of this. A development team I'm working with has a bug count that is spiriling out of control. Having talked to the developers and looked at the code it wasn't hard to see why. There has been very little thought put into overall design of the system and more copy and paste code than I think I ever seen (a friend of mine swears that the copy and paste function should be removed from all development software). So I talked to them about writing a few unit test. Before addressing a bug, write a test. Once it it running (and presumably failing), fix the bug. That way you slowly build up a test suite. Okay yeah, that easy, they said. Last week I went in to see them again there where a number of new bugs so I asked to take a look at the tests. Not one had been written. I restated that it was going to be an up hill battle trying to stabilise the system if they don't start writing tests. They said that the code was too hard to write test for. So I sat down with them and wrote a test for one of the bugs. Along the way I refactored the underlying code a little to make working with the test system a little easier and fixed the bug. I then refactored the code some more to get rid of some copy and paste. Ran the test, all green, sweet. Oh, that was easy they said. Today I got a call. Bugs had let bitten them again in areas they'd fixed two days before. Again I asked about the tests. Mine was the only one they had. Sometimes getting developers to change their ways is more force than logic. Tommorrow I'm taking a hammer in with me :) TrackBackAdopting the "write a test, write the code" approach needs a "cultural" change. Unfortunately, cultural change is far more difficult to introduce than technological change. You'll probably end up with a VERY strong arm from using that hammer... --Lee, September 24, 2003 07:20 PM
I'm slowly winning the cultural battle at my new company. I've got one guy test addicted, and the other one is seeing the advantages. Its not a full test before you code enviroment (I'm still guilty of non compliance at times), but when it works, it really works. Thanks Kev! (I blame you for the XP infection :D) --Robin Harrison, September 25, 2003 08:42 PM
sem sem --sami, December 8, 2006 04:59 PM
Post a comment
|