Better late than never, I finally hopped aboard the test driven development band wagon. Armed with Google Test, I'm beginning to make testing part of the early stages of my development process. There are probably lists that detail all the benefits to test driven development, and you can and should search for them on your own. But some benefits that I've personally experienced and felt are:
- Thinking about testing makes me write better code. If you want to write unit tests, you need to separate your program into distinct modular components, so you can test one part at a time. Of course, writing small byte-size units of code is generally a good programming practice anyway - so that's one win-win.
- Testing gives you confidence. All programs have some bugs, but testing helps you out in a few ways.
- Before you check in code, testing might help you catch a bug. So, buggy code doesn't enter your repository. Nobody but you knows that you're a sloppy programmer!
- After your code has rolled out to the world, your test might find a bug before any user's notice it. Although not ideal, maybe you can roll back changes or submit a fix before any clients begin complaining. Only your coworkers know you made a mistake!
- One of your clients spots a bug and you get called up to fix it. Testing will help you isolate the problem. You know what tests have been written and what edge cases haven't thoroughly been tested. Hopefully your tests help you fix the problem faster. So, your clients know that you had bugs, but they marvel at your customer service.
Now that I've experienced some of the benefits of testing, I can't imagine writing code without them.
No comments:
Post a Comment