Boundary value analysis

Boundary value analysis is a test design technique that chooses test inputs at the edges of the ranges a program accepts: the minimum, the maximum, and the values immediately on either side of each. It rests on the observation that defects cluster where a condition changes, at the off-by-one in a loop or the comparison that should have been 'or equal', rather than in the middle of a range.

The longer version

The technique starts by finding the boundaries. A field accepts a quantity from one to ninety-nine; a discount applies to orders of fifty or more; a session expires after thirty minutes. Each rule has an edge, and the analysis picks values at the edge and just beyond it: the minimum, one below the minimum, the maximum, one above the maximum, and for a threshold the value that meets it and the value that just misses. Those few inputs replace a random spread across the range, because a program that handles fifty correctly handles fifty-one the same way, and the open question is what it does with forty-nine.

It is taught alongside equivalence partitioning, which divides the input space into classes the program should treat identically and tests one value from each class, and the two are applied together: partitioning finds the classes, boundary analysis tests where they meet. The technique differs from edge-case testing in intent, though the words overlap. A boundary is derived from a stated rule and is systematic; an edge case is any unusual condition, stated or not, including ones no rule mentions.

Boundaries hide in places nobody wrote a rule for. The end of the month is a boundary for every date calculation, and the last day of February is a boundary for the boundary. The empty string, the single character and the character limit plus one are boundaries of every text field. A form that validates the count client-side and trusts it server-side has two boundaries that can disagree. The analysis fails when the tester takes the specification's boundaries as the only ones; it is most useful when applied to the boundaries the specification forgot.

Common questions

What is the difference between boundary value analysis and equivalence partitioning?

Equivalence partitioning divides the inputs into classes the program should treat the same way and tests one representative from each class. Boundary value analysis tests the values where those classes meet, on both sides of each edge. Partitioning decides which regions to test; boundary analysis decides which values inside them are most likely to fail.

Which values does boundary value analysis test?

For each boundary, the value on the boundary itself and the values immediately on either side of it: the minimum and one below, the maximum and one above, and for a threshold the value that meets it and the one that just misses. Some teams add a typical value from inside the range as a control case.

Is boundary value analysis black box or white box?

Black box. The boundaries come from the specification, the field's rules and the domain, not from reading the code, so the technique is applied by testers who never see the implementation. Reading the code afterwards often reveals boundaries the specification did not state, and those get added to the same analysis.

Why do defects cluster at boundaries?

Because a boundary is where the code makes a comparison, and comparisons are where a developer writes less-than when the rule said less-than-or-equal, starts a loop at one instead of zero, or checks the limit on the client and forgets it on the server. Inside a range the code follows one path for every value; at the edge it chooses between two, and the choice is what gets written wrong.

Can boundary value analysis be applied to dates and text fields?

Dates and text have boundaries like any other input. For dates they are the end of the month, the end of the year, the last day of February and the moment a time zone changes. For text they are the empty string, one character, the character limit and one past it, plus a character outside the expected script. Each is treated as a threshold and tested on both sides.

Bug reports that arrive ready to triage.

Collect replay, console, network and browser context with the Free plan.

<script src="…/widget.js" data-key="pb_pub_…">