A Simple, Hands-on, Introduction to Test Driven Development (TDD)

Learn how TDD works by actually doing it.

It's very easy.

All you need:

  • 45 - 90 minutes,

  • Microsoft Excel, and

  • (perhaps) a friend who can write a little code.

Suitable for Managers, Testers, Analysts, and Developers, of all shapes and sizes.

You build your working software up small incremental steps, one test at a time. This cuts down hugely on the amount of time required to rework code to fix defects and time can, instead, be used to refactor the code, keeping the code-base clean, well designed and malleable, so it is easy and cheap to work with. Significantly Less rework + significantly easier code = Significantly higher productivity.Even better, the tests act as a safety net – catching your mistakes quickly so that they are cheaper and easier to fix. That's an easy process to describe, but that's not enough: it’s only when you do it that you truly get it.

How do you try TDD, for real, if you’re not a programmer?

How do you persuade your boss to let you do TDD, if he or she can’t truly get it?

Here's how. This site runs through a very simple TDD example – converting integers into their roman number equivalent - that you or your boss can do easily using Microsoft Excel and Visual Basic for Applications (VBA). It’s not intended to teach how to do TDD or how to program, but rather it’s a hands on example where you can get a feel for the process and the possibilities.

All you need is Excel, an open mind and an hour or so to experiment. It will help if you’ve had a little programming experience … but not much.

The process looks like this:

  • You add test data into a spreadsheet (1=i, 2=ii, 3=iii, etc) one test at a time.

  • You write a new Excel function using Visual Basic for Applications (VBA) to make each test work, as it is added.

  • You set up conditional green and red formatting in the spreadsheet to tell you quickly and visually when the tests are passing and failing.

Now lets create your first test and setup your test environment.

  1. Test Driven Development (TDD) is easy to describe: Write a failing test,

  2. Make the test run,

  3. Refactor (clean up) the code so the design is cleaner, and

  4. Repeat for the next test.