Test First is Not Optional

Some agile teams do well. Many don't. In my experience, there is one consistent thing that separates the teams that succeed from those that fail and that is sound engineering practices. Foremost among those sound practices is Test First (or Test Driven) design.

Having a solid test suite that runs frequently is a key to agility. By frequently I mean every night at least. Without frequent regression testing, teams become risk averse and unwilling to make changes in case something breaks. In an agile environment where change is encouraged, this can be a death sentence for an agile project.

Up until 10 years ago, frequent regression testing was just a dream. To even consider running a full regression test suite every day on a product would have required vast armies of testers and vast budgets. Then they invented jUnit. This little utility (and its xUnit descendants) made true, automated regression testing possible for the first time.

But the ability to write automated regression tests is not enough. Unless the tests are comprehensive, well thought-out and give good coverage, they won't give the team the confidence they need to become agile. Even with automated unit tests, teams continued to turn out untested and untestable code. What was needed was a methodology to help developers write tests and testable code. That methodology is Test Driven Design.

By writing the test first, and ensuring that no code is written that doesn't have an associated test, the code is automatically fully covered by tests and also well designed for testability. Test driven design is the methodology that allows teams to become agile. With code fully covered by well defined and well maintained tests, teams can make changes freely without any fear of causing unknown problems elsewhere in the system. Unless a team is free to make changes, they can not act in an agile way.

But why stop at unit tests? By writing requirements as test cases you ensure that the requirement is testable and that an automated test can be written to test it. That way your acceptance tests can be automated and run every night as well. What better indication of project progress than an ever increasing percentage of passed tests?

While there are other engineering practices that are useful in an agile team, only test driven design (and a test first philosophy in general) is so critical to success.