Boundaries

Bugs like the value on the line, not the middle of a class.

A boundary is the value where the rule changes. If adult age starts at 18, the interesting values are 17, 18 and sometimes 19. The middle of the class, the number 40, adds little once one adult has been checked. Defects of "greater than" versus "greater than or equal" live exactly on the line.

Look at both sides and at the line itself. For a name length of up to 50 characters inclusive, check 50, 51, and 0 or empty if empty is a separate case. 49 is useful only if you suspect an off-by-one error. You do not have to drag in everything, but you must not drop 50 and 51.

Boundaries are not only numeric. The first element of a list, an empty list, a single element, overflowing a page of pagination, midnight, 29 February, a change of time zone. "There is no numeric field" does not mean "there is no boundary".

In a report on a set of checks, name the boundary explicitly: "18 is accepted, 17 is not". If only 40 was accepted, the set looks long and still misses the classic comparison defect. The length of a checklist does not replace closeness to the line.

Practice

  1. Which ages matter more

    Adult age starts at 18 inclusive. What do you check first?

    • Only 40
    • 17 and 18
    • Only 100
    • Whatever number comes to mind first
  2. Length 50 inclusive

    Which two lengths are mandatory for a limit of 50? Write the two numbers joined by "and".

  3. Where else boundaries live

    Select the boundaries that are not numeric.

    • An empty list
    • 29 February
    • The middle of an already checked valid text
    • A random Tuesday with no special rule