Tuesday, 28 October 2008

Do you write unit tests?

I find Cay Horstmann's comments on unit testing in the article disturbing.

"I perform an occasional unit test after I've encountered a failure that I don't want to have recur, but I rarely write the tests first. If so many experienced developers don't write unit tests, what does that say? Maybe they would be even better developers if they followed Heinz's advice. Maybe they don't make many mistakes that unit tests would catch because they're already experienced. The truth is probably somewhere in between." Cay Horstmann Professor of Computer Science, San Jose State University.

It says to me that they are either lazy, stupid or not experienced developers. To me there is no in between. If these developers wrote unit tests they absolutely would be better programmers. It's a shame they will never be because they are too arrogant to admit they make mistakes.

At least Heinz Kabutz has got it right when he says that not writing unit tests is the biggest mistake even experienced developers make. I agree with Heinz 100%

So what about you? Do you write unit tests? Do you always write them first?