Chapter 18. Daily Build and Smoke Test

image with no caption

The Daily Build and Smoke Test is a process in which a software product is completely built every day and then put through a series of tests to verify its basic operations. This process is a construction-stage process, and it can be initiated even when projects are already underway. The process produces its savings by reducing the likelihood of several common, time-consuming risks—unsuccessful integration, low quality, and poor progress visibility. The process provides critical control for projects in recovery mode. Its success depends on developers taking the process seriously and on well-designed smoke tests. The Daily Build and Smoke Test can be used effectively on projects of virtually any size and complexity.

Efficacy

Potential reduction from nominal schedule:

Good

Improvement in progress visibility:

Good

Effect on schedule risk:

Decreased Risk

Chance of first-time success:

Very Good

Chance of long-term success:

Excellent

Major Risks

  • Pressure to release interim versions of a program too frequently

Major Interactions and Trade-Offs

  • Trades small increase in project overhead for large reduction in integration risk and improvement in progress visibility

  • Especially effective when used in conjunction with Miniature Milestones

  • Provides support needed for incremental-development lifecycle models

If you have a simple computer program that consists of only one file, building the program consists of compiling and linking the file to create an executable program. On a typical team project that involves dozens, hundreds, or even thousands of files, the process of creating an executable product becomes more complicated and time-consuming. The product must be "built" in order for it to run.

In the daily-build-and-smoke-test process, the entire product is built every day. That means that every file is compiled, linked, and combined into an executable program every day. The product is then put through a "smoke test," a relatively simple test to see whether the product "smokes" when you turn it on.

This simple process produces significant time savings on several fronts.

It minimizes integration risk. One of the greatest risks that a project faces is that when team members combine or "integrate" the code that they have been working on separately, their code does not work well together. Depending on how late in the project such an incompatibility is discovered, debugging might take longer than it would have if integration had occurred earlier—because program interfaces might have to be changed, or major parts of the system might have to be redesigned and reimplemented. In extreme cases, integration errors have caused projects to be canceled. The daily-build-and-smoke-test process keeps integration errors small and manageable, and it prevents runaway integration problems.

image with no caption

For more on software integration, see Chapter 27, "System Integration," in Code Complete (McConnell 1993).

It reduces the risk of low quality. Related to the risk of unsuccessful or problematic integration is the risk of low quality. By minimally smoke testing all the code in the product every day, quality problems are prevented from taking control of the project. You bring the system to a known, good state, and then you keep it there. It is simply not allowed to deteriorate to the point where time-consuming quality problems can occur.

CROSS-REFERENCE

For details on the effect that low quality has on a development schedule, see Quality-Assurance Fundamentals, "Quality- Assurance Fundamentals."

It supports easier defect diagnosis. When the product is built and tested every day, it's much easier to pinpoint why the product is broken on any given day. If the product worked on Day 17 and is broken on Day 18, something that happened between the builds on Days 17 and 18 broke the product. If you're building and testing the product only weekly or monthly, the problem could be anywhere between Day 17 and Day 24, or between Day 17 and Day 47.

image with no caption

It supports progress monitoring. When you build the system every day, the features that are present and not present are obvious. Both technical and nontechnical managers can simply exercise the product to get a sense of how close it is to completion.

It improves morale. As Fred Brooks points out, an incredible boost in morale results from seeing a product work. It almost doesn't matter what the product does; developers can be excited just to see it display a rectangle! With daily builds, a little bit more of the product works every day, and that keeps morale high.

It improves customer relations. If daily builds have a positive effect on developer morale, they also have a positive effect on customer morale. Customers like signs of progress, and daily builds provide signs of progress frequently.

Using the Daily Build and Smoke Test

The idea behind the daily-build-and-smoke-test process is simple: build the product and test it every day. The following sections describe some of the ins and outs of this simple idea.

Build daily. The most fundamental part of the daily build is to build the product every day. As Jim McCarthy says, treat the daily build as the heartbeat of the project (McCarthy 1995c). If the heart isn't beating, the project is dead.

A little less metaphorically, some describe the daily build as the synch pulse of a project (Cusumano and Selby 1995). Different developers' code can get a little bit out of synch between synch pulses, but with each synch pulse, all the code has to come back into alignment. When you insist on keeping the pulses close together, you prevent some developers from getting out of synch entirely.

Use an automated build tool (such as make) to reduce the repetitive work associated with building daily.

Check for broken builds. In order for the daily-build process to be effective, the software that's built has to work. If the software isn't usable, the build is considered to be broken, and fixing the build becomes top priority.

Each project sets its own standard for what constitutes "breaking the build." The standard needs to set a quality level that's strict enough to keep showstopper defects out of the daily build but lenient enough to disregard trivial defects (because undue attention to trivial defects can paralyze progress).

At a minimum, a good build should:

  • Compile all files, libraries, and other components successfully

  • Link all files, libraries, and other components successfully

  • Not contain any showstopper bugs that prevent the program from being launched or that make it hazardous to operate

  • Pass the smoke test

Some projects set stricter standards and include compiler and linker errors and warnings in their definitions of good builds. The litmus test in any case is whether the build is stable enough to be released to testing. If it's stable enough to test, it isn't broken.

Smoke test daily. The smoke test should exercise the entire system from end to end. It does not have to be an exhaustive test, but it should be capable of detecting major problems. By definition, if the build passes the smoke test, that means that it is stable enough to be tested and is a good build.

Without the smoke test, the daily build is meaningless. The smoke test indicates whether the build worked. If you treat the build itself as the heartbeat of the project, the smoke test is the stethoscope that allows you to determine whether the heart is beating. It is the first line of testing, the first line of defense against program deterioration. Without the smoke test, the daily build is just a way of verifying that you have a clean compile.

The smoke test must evolve as the system evolves. At first, the smoke test will probably be something simple, such as testing whether the system can say, "Hello World." As the system develops, the smoke test will become more thorough. The first test might take a matter of seconds to run. As the system grows, the smoke test can grow to thirty minutes, an hour, or more.

The build group should make maintaining the smoke test its top priority. The quality of their work on the smoke test should factor into their performance evaluations. The build group will be under pressure from the developers not to make the smoke test too "picky," so its members should be chosen from the ranks of quality assurance rather than from the ranks of developers. Regardless of everyone's best intentions, putting a developer in charge of the smoke test is too much like putting a fox in charge of the chicken coop. The group's members should report to the QA lead rather than to the development lead.

This is one of the areas in which designing your system for testing comes in handy. The smoke test should be automated, and sometimes it's easier to automate if you have built-in hooks for testing.

Establish a build group. On most projects, tending the daily build becomes a big enough task that it needs to be an explicit part of someone's job. On large projects, it can become a full-time job for more than one person. For example, on Windows NT 3.0, there were four full-time people in the build group (Zachary 1994). It also takes effort to keep the smoke test up to date as the product grows and evolves.

On smaller projects you might not need to devote a whole person to the daily build. In that case, put someone from quality assurance in charge of it.

Add code to the build only when it makes sense to do so… Although daily builds require that you build the system daily, they do not require that developers add every new line of code they write to the system every day. Individual developers usually don't write code fast enough to add meaningful increments to the system every day. They work on a chunk of code and then integrate it when they have a collection of code in a consistent state. Developers should maintain private versions of the source files they're working on. Once they have created a complete set of modifications, they make a private build of the system using their modifications, test it, and check it in.

…but don't wait too long to add code to the build. Although few developers will check in code every day, beware of developers who check in code infrequently. It's possible for a developer to become so embroiled in a set of revisions that every file in the system seems to be involved. That undermines the value of the daily build. The rest of the team will continue to realize the benefit of incremental integration but that particular developer will not. If a developer goes more than a few days without checking in a set of changes, consider that developer's work to be at risk.

Require developers to smoke test their code before adding it to the system. Developers need to test their own code before they add it to the build. A developer can do this by creating a private build of the system on a personal machine, which the developer then tests individually. Or the developer can release a private build to a "testing buddy," a tester who focuses on that developer's code. The goal in either case is to be sure that the new code passes the smoke test before it's allowed to influence other parts of the system.

image with no caption

For many details on developer-level testing practice, see Writing Solid Code (Maguire 1993).

Create a holding area for code that's to be added to the build. Part of the success of the daily-build process depends on knowing which builds are good and which are not. In testing their own code, developers need to be able to rely on a known good system.

Most groups solve this problem by creating a holding area for code that developers think is ready to be added to the build. New code goes into the holding area, the new build is built, and if the build is acceptable, the new code is migrated into the master sources.

On small- and medium-sized projects, a version-control system can serve this function. Developers check new code into the version-control system. Developers who want to use a known good build simply set a date flag in their version-control–options file that tells the system to retrieve files based on the date of the last-known good build.

On large projects or projects that use unsophisticated version-control software, the holding-area function has to be handled manually. The author of a set of new code sends email to the build group to tell them where to find the new files to be checked in. Or the group establishes a "check-in" area on a file server where developers put new versions of their source files. The build group then assumes responsibility for checking new code into version control after they have verified that the new code doesn't break the build.

Create a penalty for breaking the build. Most groups that use daily builds create a penalty for breaking the build. If the build is broken too often, it's hard for developers to take the job of not breaking the build seriously. Breaking the build should be the exception, not the rule. Make it clear from the beginning that keeping the build healthy is the project's top priority. Refuse to take a broken build casually. Insist that developers who have broken the build stop their other work until they've fixed the build.

A fun penalty can help to emphasize the priority of keeping the build healthy. Some groups give out suckers to developers who break the build. The sucker who broke the build has to tape a sucker to his office door until he fixes the build. Other projects make the person who broke the build responsible for running the build until someone else breaks it. On one project I worked on, the person who broke the build had to wear a hat made out of an umbrella until he fixed the build. Other groups have guilty developers wear goat horns or contribute $5 to a morale fund.

Some projects establish a penalty with more bite. Microsoft developers on high-profile projects such as NT, Windows 95, and Excel have taken to wearing beepers in the late stages of their projects. If they break the build, they are called in to fix the build regardless of the time of day or night. The success of this practice depends on the build group being able to determine precisely who broke the build. If they aren't careful, a developer who's mistakenly called to fix the build at 3:00 in the morning will quickly become an enemy of the daily-build process.

Release builds in the morning. Some groups have found that they prefer to build overnight, smoke test in the early morning, and release new builds in the morning rather than the afternoon. There are several advantages to smoke testing and releasing builds in the morning.

First, if you release a build in the morning, testers can test with a fresh build that day. If you generally release builds in the afternoon, testers feel compelled to launch their automated tests before they leave for the day. When the build is delayed, which it often is, the testers have to stay late to launch their tests. Because it's not their fault that they have to stay late, the build process becomes demoralizing.

When you complete the build in the morning, you have more reliable access to developers when there are problems with the build. During the day, developers are down the hall. During the evening, developers can be anywhere. Even when developers are given beepers, they're not always easy to locate.

It might be more macho to start smoke testing at the end of the day and call people in the middle of the night when you find problems, but it's harder on the team, it wastes time, and in the end you lose more than you gain.

Build and smoke even under pressure. When schedule pressure becomes intense, the work required to maintain the daily build can seem like extravagant overhead. The opposite is true. Under pressure, developers lose some of their discipline. They feel pressure to take design and implementation shortcuts that they would not take under less stressful circumstances. They review and unit test their own code less carefully than usual. The code tends toward a state of entropy more quickly than it would during less stressful times.

image with no caption

Against this backdrop, the daily-build-and-smoke-test process enforces discipline and keeps pressure-cooker projects on track. The code still tends toward a state of entropy, but you bring that tendency to heel every day. If you build daily and the build is broken, identifying the developer responsible and insisting on an immediate code fix is a manageable task. Bringing the code back from its state of entropy is a relatively small undertaking.

If you wait two days—until twice as many defects are inserted into the code—then you have to deal both with twice as many defects and with multiplicative interaction effects of those defects. It will take more than twice as much effort to diagnose and correct them. The longer you wait between builds, the harder it is to bring the build back into line.

What Kinds of Projects Can Use the Daily-Build-and-Smoke-Test Process?

Virtually any kind of project can use daily builds—large projects, small projects, operating systems, shrink-wrap software, and business systems.

Fred Brooks reports that software builders in some organizations are surprised or even shocked by the daily-build process. They report that they build every week, but not every day (Brooks 1995). The problem with weekly builds is that you tend not to build every week. If the build is broken one week, you might go for several weeks before the next good build. When that happens, you lose virtually all the benefit of frequent builds.

Some developers protest that it is impractical to build every day because their projects are too large. But the project that was perhaps the most complex software-development effort in recent history used daily builds successfully. By the time it was first released, Microsoft NT consisted of 5.6 million lines of code spread across 40,000 source files. A complete build took as many as 19 hours on several machines, but the NT development team still managed to build every day (Zachary 1994). Far from being a nuisance, the NT team attributed much of their success on that huge project to their daily builds. Those of us who work on projects of less staggering proportions will have a hard time explaining why we don't use daily builds.

For technical leads, daily builds are particularly useful because you can implement them at a purely technical level. You don't have to have management authority to insist that your team build successfully every day.

Daily builds are especially valuable in project-recovery mode. If you can't get to a good-build state, you have no hope of ever shipping the product, so you might as well work toward a good build as one of your first project-recovery objectives. Once you get to a known good state, you make incremental additions and stay in a known good state. It's a morale boost during project recovery to have a working product at all times, and it makes for clear progress indications.

CROSS-REFERENCE

For more on project recovery, see Chapter 16, Chapter 16.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.160.181