Page 173 -
P. 173
with a substantial amount of example code, but they also show her all of the behavior that
the object is meant to exhibit, including the errors that it is expected to handle.
NOTE
Additional information, tutorials, and examples of unit testing can be
found in Pragmatic Unit Testing by Andrew Hunt and David Thomas (The
Pragmatic Bookshelf, 2003).
Use Automation
There are many tasks over the course of a software project that can be automated. Unit
tests are a good example of automation—before programmers started using automated
unit tests, they had to manually verify each function and user interface element before
delivering a build. By automating unit tests, the programmers were able to make them
much less time-consuming tasks and, as a result, many more programmers take the time
to build unit tests.
But unit tests are not the only manual programming task that can be automated. Automa-
tion can ensure that the software is built the same way each time, that the team sees every
change made to the software, and that the software is tested and reviewed in the same
way every day so that no defects slip through or are introduced through human error.
When projects become complex and require many steps to build, it’s easy for program-
mers to forget a step. A programmer may build a version of the software that is missing a
library, or is compiled with incorrect options. What’s more, some programming teams
have discovered that, as their build process becomes more and more complex, they have
to dedicate more of a senior team member’s time to generating new builds on a regular
basis, which can cause delays in the project. Eventually, it becomes difficult for the team
to even generate a reproducible build. When the build is delivered to users, there are often
defects that can be traced back to missing libraries, or to required files that should have
been included.
There are many automated build tools that address all of the problems caused by an
unpredictable and difficult-to-reproduce build process. Popular ones include:
• Make (which ships with most Unix-like operating systems and some IDEs)
• GNU Make (http://www.gnu.org/software/make)
• Apache Ant (http://ant.apache.org)
• Jam (http://www.perforce.com/jam/jam.html)
Each of these tools automates a set of steps required to build the project. There are ways to
ensure that dependencies are honored, so that a piece of code is only built after the tool
first builds every library that it depends on. With an automated build tool, a programmer
can cut a new build at any time and without extra input or interaction. The team can be
DESIGN AND PROGRAMMING 165