“Doesn’t unit testing add code effort?”
If I had a dollar for every time I was asked that question…. People use this as an excuse not to begin writing tests.
I used to say: “You know, industry standards say it’s 20 percent more, but it’s worth it”.
Not anymore. No more buts.
Unit testing and TDD helps you release better products quickly. Period.
“But we’ll be writing more code!”
Maybe. Or maybe you’ll write less code, because you’ll have a better design. And then you’ll spend less time on hacking fixes.
“But we’ll spend more time on writing tests!”
Yes, because you’re not writing tests now. That’s inevitable. In the meantime, you’ll have less bugs. Which means you’ll be debugging a lot less. And that means you’ll finish features quickly, not five times in the next 3 months. You know – “it’s done except for those bugs the testers found”.
“But now we’ll spend time fixing tests!”
Yes, you will. While you learn how to write tests, you’ll stumble. And then you’ll learn how to write smart tests, that don’t break easily. And it’s still better than debugging for days until you reproduce a bug, and debugging more to prove it’s fixed.
Industry standards talk about programmers writing 10 lines of code a day. Good developers remove this excess per day, but let’s stick to the “standards” for a minute. You mean to tell me that 2 extra lines a day will make you work a lot more?
No more excuses, no more buts.
Start writing tests today.