3.13 Preventing Build Breaks

3.13.1 Problem

You are concerned because developers keep "breaking the build" by checking in broken code to your version control tool.[3]

[3] A version control tool is something like CVS or Microsoft Visual SourceSafe.

3.13.2 Solution

Adopt a policy in which developers must perform a clean build using Ant before checking in changes to the source repository. Ask them to run all unit tests, as well.

3.13.3 Discussion

This is largely a project management issue. If your team has an Ant buildfile along with a suite of unit tests, the build should not be breaking on a routine basis. Understand that people do make mistakes, such as forgetting to commit some changes to CVS despite having tested their changes.

Each developer should follow these suggestions in order to minimize integration problems:

  • Work in pairs. Your partner should encourage you to follow the full testing procedure before checking in code.

  • Work on one problem at a time. Keeping track of dozens of changes for days at a time is a good way to get out of sync with the rest of the team and introduce build problems.

  • Perform a clean build before testing changes.

  • Run the entire suite of unit tests before committing changes to the version control tool.

3.13.4 See Also

Chapter 1 and Chapter 2 discuss XP practices such as continuous integration and pair programming.