Over the last month I’ve switched to using test driven development. It’s definitely made programming more enjoyable, and less stressful (not that it was all that stressful to begin with).

Here are a few of the benefits I’ve found from using test driven development:

I don’t have to maintain a mental model of the program I am building. I can offload that responsibility to the computer.

Before I implemented TDD I would try to keep a mental model of the program I was building, while also trying to think of anything that might go wrong.

Now I don’t worry about it. I can offload the mental model onto the computer.

I’m able to focus on a single feature at a time, and the computer will tell me if I’ve broken anything.

I don’t have to perform manual browsers tests, which means a faster development cycle.

I hate doing manual browser tests; they’re slow and tedious.

My old development flow roughly consisted of:

  1. Load up a form, in the browser, with the properly formatted data.
  2. Submit the form
  3. Check sequel pro
  4. Debug (if necessary)
  5. Rinse and Repeat

TDD has allowed me to shorten my development cycle to:

  1. Write a test
  2. Make the test pass
  3. ???
  4. Profit

It alleviates the nagging feeling that something, somewhere, is broken.

Prior to using TDD, adding features was kind of like the wild west. When asked if the new feature worked, I’d say “It worked when I created the pull request”, and we’d push it to production.

It was impossible to know if I’d introduced a bug into the system, and since there were no tests to tell me otherwise, I always assumed I had.

With TDD, those days are gone! If the test suite passes before I commit, I can say - with confidence - that the system is working as it’s designed.

The next step is to write faster tests.