Test First Development

Nov 27th, 2002 by Tony in Questioning XP

Of all the practices of XP, Test First Development is the most counterintuitive of them all. It is probably also the most powerful of them all for promoting the necessary paradigm shift for understanding and benefiting from XP. The idea behind Test First Development is very simple: before you change the behaviour of the production code you must have a failing test.

A failing test is immensely useful because it tells you when you are done. By shifting the traditional sequence of development around so that the test are the first things that are created, developers get feedback about whether their code is correct within seconds of writing the code.

This has a very dramatic effect on the feel of programming and goes a long way toward addressing concerns about the defect rate.

Test First Development feels exceedingly strange for programmers when they first encounter it. In the old days, programmers used to pride themselves on the fact that they could write an entire program and have it compile error free the first time. Now they are expected to get lots of errors deliberately every day. Although this feels really natural for XP developers, getting developers even to attempt this style can be difficult.

— Pete McBreen, Questioning Extreme Programming, Chapter 8

No Comments