20.9. Test-First Programming

An excellent practice promoted by the Extreme Programming (XP) method [Beck00], and applicable to the UP (as most XP practices are), is test-first programming. In this practice, unit testing code is written before the code to be tested, and the developer writes unit testing code for all production code. The basic rhythm is to write a little test code, then write a little production code, make it pass the test, then write some more test code, and so forth.

Advantages include:

  • The unit tests actually get written— Human (or at least programmer) nature is such that avoidance of writing unit tests is very common, if left as an afterthought.

  • Programmer satisfaction— If a developer writes the production code, informally ...

Get Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.