Приглашаем посетить
Татищев (tatischev.lit-info.ru)

Section 12-3.  Debugging Tests

Previous
Table of Contents
Next

12-3. Debugging Tests

When you get a defect report, your impulse might be to fix the defect as quickly as possible. Experience shows that this impulse will not serve you well; it is likely that the fix for the defect will cause another defect.

You can hold your impulse in check by doing the following:

  1. Verifying that you can reproduce the defect.

  2. Finding the smallest-scale demonstration of the defect in the code. For example, if a number appears incorrectly in an output, find the object that is computing that number.

  3. Writing an automated test that fails but will succeed when the defect is fixed.

  4. Fixing the defect.

Finding the smallest reliable reproduction of the defect gives you the opportunity to really examine the cause of the defect. The test you write will improve the chances that when you fix the defect, you really fix it, because the new test reduces the likelihood of undoing the fix with future code changes.

All the tests you wrote before reduce the likelihood of inadvertently causing a different problem.


Previous
Table of Contents
Next