The Art of Software Testing, Second Edition
by Glenford J. Myers, Corey Sandler, Tom Badgett, Todd M. Thomas
7.4. Debugging by Backtracking
An effective method for locating errors in small programs is to backtrack the incorrect results through the logic of the program until you find the point where the logic went astray. In other words, start at the point where the program gives the incorrect result—such as where incorrect data were printed. At this point you deduce from the observed output what the values of the program's variables must have been. By performing a mental reverse execution of the program from this point and repeatedly using the process of "if this was the state of the program at this point, then this must have been the state of the program up here," you can quickly pinpoint the error. With this process you're looking for the location in the program between the point where the state of the program was what was expected and the first point where the state of the program was what was not expected.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access