Choosing Boundary Test Cases

A boundary test checks the values at and immediately around a place where the intended outcome changes.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Choose adjacent cases
  2. Test structural boundaries too
  3. Choose distinct values immediately around the exact cutoff
  4. Check more than the returned boolean

Choose adjacent cases

If a service accepts integer quantities from one through ten, use 0, 1, 10, and 11. The pairs reveal whether the minimum and maximum are inclusive. Their interpretation belongs in the function contract.

Test structural boundaries too

A scan can succeed on ten items and fail on zero because initialization expects an element. Add lengths zero, one, and two when working with order, neighbors, or indexing. See off-by-one errors for examples where a short sequence reveals the wrong start.[1]

Choose distinct values immediately around the exact cutoff

A storage rule accepts integer counts from four through twelve. Test three, four, five and eleven, twelve, thirteen. These examples can distinguish an inclusive lower or upper comparison from a strict one. If counts are discrete, use the nearest supported value on each side. See inclusive and exclusive tests.

Count    3  4  5  11  12  13
Accept   N  Y  Y   Y   Y   N

Check more than the returned boolean

A rejected input may also need an error reason and state preservation. Test a count that passes the lower check but fails because another field is missing. That combination catches accidental interactions between independent boundaries.

References

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