Paul Bourdeaux wrote about “Top 5 excuses for not doing unit tests“, something I hear all the time. Paul makes a good case for all excuses, and I want to put a finer point on the second.
“The client does not pay me to write unit tests, he pays me to write code”. You may have heard the version where client==boss. Well it’s not completely untrue. Actually you’re getting to write code that works. Your boss or client may not care how you get it to work, but they expect it to work. Unit tests is one way to get there.
And now, prepare yourself for a shock: if you ask managers and clients, they tell you exactly that. But if you ask them – “does it happen much?” guess what they answer. And that’s because, we as developers, gave software bad reputation. In my former life as project manager, I expected builds to fail, integrations to lengthen, and QA roundtrips back to development. Because “that’s how software development is”.
It doesn’t have to be. It’s the developer’s responsibility to make sure the code works. This is how software development is supposed to be. Stop making excuses.