Chapter 7. Debugging

In brief, debugging is what you do after you have executed a successful test case. Remember that a successful test case is one that shows that a program does not do what it was designed to do. Debugging is a two-step process that begins when you find an error as a result of a successful test case. Step 1 is the determination of the exact nature and location of the suspected error within the program. Step 2 consists of fixing the error.

As necessary and as integral as debugging is to program testing, this seems to be the one part of the software production process that programmers enjoy the least. These seem to be the main reasons:

  • Your ego may get in the way. Like it or not, debugging confirms that programmers are not perfect, committing errors in either the design or the coding of the program.

  • You may run out of steam. Of all the software development activities, debugging is the most mentally taxing activity. Moreover, debugging usually is performed under a tremendous amount of organizational or self-induced pressure to fix the problem as quickly as possible.

  • You may lose your way. Debugging is mentally taxing because the error you've found could occur in virtually any statement within the program. That is, without examining the program first, you can't be absolutely sure that, for example, a numerical error in a paycheck produced by a payroll program is not produced in a subroutine that asks the operator to load a particular form into the printer. Contrast ...

Get The Art of Software Testing, 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.