In 2001 I was writing robocode robots and battling them with some co-workers. Things were going well enough — win some, lose some — when a friend suggested we try writing unit tests for our bots. Great idea! I’d been wanting to learn unit testing since at least ‘97 when I read about it on the C2 wiki.
Before I started writing the tests I thought they would help me catch those last couple of bugs in my program. Sure the average programmer wrote a bug ever 2-5 lines, but I was pretty sure I was better than average and had only a few remaining. After all, not only was I pretty careful with my code but I’d been testing and debugging my bot code for a couple of weeks.
Then I started writing the tests.
Suddenly a bug only every 5 lines sounded pretty good! How had this CRAP ever seemed to work at all?!?
Once I realized how much I sucked without tests I didn’t want to write code without them, and TDD was the most efficient way to do that.