Monday, February 25, 2008

First Stab at Test Driven Development

I recently took advantage of a mandate to rip out the most complex part of my app and rebuild it from scratch. I had deep experience with the application already so this was much easier. The requirements were set in stone so I knew all the different unit tests I had to write. For a lot of reasons this functionality didn't get enough dev and test time during implementation and it came back to bite every few months. The defects were always corner cases too. Grr.

This time I created interfaces and stubbed out some classes. I knew what I needed to test for so I wrote JUnit tests before implementing the real deal.

As I was developing the new code, it was such an awesome experience to catch bugs minutes after they're introduced. A few days later when I finished rewriting the logic, I was pretty confident in what I had written. Every day the tests would run dozens of times. I've never had this much reassurance before...

No comments: