Archive for the 'General Development' Category

Unit Testing isn’t necessary once you get a bit of experience down you…

What a crock. Following hot on the heels of Phil’s ‘Old developers get on my nerves and smell of soap’ post (not altogether accurate quote, more paraphrasing) I stumbled, via hanselminutes across this load of old tosh…

It appears that once you have 21 years of development experience under your belt you can divine whether your code works correctly using the force.

I have not really got into ‘Test Driven Development’ myself, now that isn’t to say it hasn’t got its merits, but my brain doesn’t work that way at the moment. I at least get a class defined with some method stubs in before I think about unit tests. I very often fill the methods out and I am sure there will be XP purists that balk at that.

I have in the last year written an application that because of time pressure I decided to do away with writing the unit tests. I think this is a reasonable decision to take if there just isn’t room to fit them in. I wish I had though as six months later the client was back for some new features that involved a bit of a reworking of some of the old stuff and it was a nightmare without the unit tests available.

You see, I am of the opinion that to consider unit tests as purely a time consuming mechanism for finding bugs is to undersell them. Bugs will out eventually, unit tests or not but the big thing for me, and the thing that gives the payback for writing them in the first place is when you come to do some refactoring or other. Particularly when things have got a bit out of hand. To be able to instantly see what has broken as a result of your changes is where it is at for me with unit testing. You also can’t argue that if you are able to automatically run a defined, possibly 100%, amount of your public APIs with every build then you are going to have a more robust application at the end of it than if you arbitrarily give it a manual runout.

The ‘time consuming’ argument is not really holding water these days either. I mean, you still have to write some stuff but there are plenty of tools that can lend a hand. Just out of the ones I have had a play with you have CodeRush that has some templates, Visual Studio will generate tests for you that need a bit (or a lot at times) of editing and there is nothing stopping you generating them with CodeSmith or any of the other miriad of code gen tools.

Judging from the comments Wil Shipley isn’t alone. I don’t mind people like that though…

…because they are wrong.