Reproducing an Ordinary Program Bug

A useful reproduction specifies the initial state, exact input, observed behavior, and expected outcome for a single defect.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Keep the original evidence
  2. Remove unrelated inputs
  3. Record the starting state and exact action sequence
  4. Reproduce before changing several things at once

Keep the original evidence

For a report missing its final line, save a small input file and whether the last record ends in a newline. Verify the expected output with a plain-text comparison. Line iteration explains why this particular input boundary can matter.

Remove unrelated inputs

If a two-line file still fails, compare it with a one-line file and another with a terminator. Record the relevant runtime and settings with the program run so another maintainer can replay it.[1]

Record the starting state and exact action sequence

Suppose a second save incorrectly duplicates a line. Create an empty note, save after adding A, then save again without edits. The expected persistent state remains one A. Capture what actually happened and the environment used. See state sequence tests.

Starting file empty
Save input A → expects one line
Save unchanged input A again → still expects one line
Failure signature: A appears twice

Reproduce before changing several things at once

A restart between saves may clear relevant memory and make the bug disappear. Try that as a separate comparison. Save a minimal fixture when failure is stable enough to serve as a regression check.

References

  1. Python Software Foundation, unittest: Unit Testing Framework ↩