Finding a Smaller Failing Input

Reduce a failing input by removing features whose presence is unnecessary for observing the same defect.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Preserve the observed failure
  2. Check a changed symptom
  3. Remove one irrelevant part and rerun the same check
  4. Retain the reason the small fixture is representative

Preserve the observed failure

A CSV report with one hundred rows may fail after a row containing a comma inside a quoted field. Delete blocks of rows and rerun the same check. Keep a saved copy so you can confirm the smaller input produces the same result, following a reproducible run.

Check a changed symptom

If the reduced input now fails during header parsing, it exposes another behavior. Restore the required header and continue simplifying. Reading original input and output helps define what to preserve.[1]

Remove one irrelevant part and rerun the same check

A report made from twenty rows fails after encountering two adjacent records with an equal primary key. Reduce the fixture by removing blocks. Keep rows needed to preserve the equal-key condition and the observable failure. See reproducing a bug.

Full fixture: 20 rows, failure
Remove unrelated half: 10 rows, still fails
Keep just tied pair with different IDs: still fails
Keep only one of the pair: passes

Retain the reason the small fixture is representative

A reduction can accidentally trigger a different error before reaching the original defect. Compare exception location or incorrect output when each smaller fixture fails. Record the preconditions that must remain, such as data order.

References

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