QA GLOSSARY · TERM 2 OF 6
Boundary value analysis
Boundary value analysis is a way to choose test inputs. Bugs gather at the edges of a rule, so for every limit you test the value just below it, exactly on it and just above it. Two of the six bugs in this site's QA challenge are boundary bugs.
The idea
Almost every rule in software has an edge: a smallest quantity, a longest name, a price at which something changes. Code is most often wrong exactly at the edge, because the person who wrote it was thinking about the middle. A tester who only tries typical values will rarely find these bugs. A tester who goes to the edges finds them quickly.
The recipe is short. Find every limit. For each one, test the value just below it, the value on it and the value just above it. The challenge's own advice is the same: test every threshold three ways.
Two real boundary bugs from the QA challenge
| Bug | The limit | What goes wrong |
|---|---|---|
| BUG-01, quantity can go below zero | The smallest allowed quantity | The quantity has no lower limit, so it can go negative. A negative line total makes the order total negative: the shop would be paying the customer. |
| BUG-05, free shipping fails at exactly $50 | The $50 threshold | Shipping is free on orders of $50 or more, but the code says "more than $50". At exactly $50.00 a $5 fee is still added. |
The second one is the textbook case. A tester who tries $30 and $80 sees nothing wrong. Only $50.00 shows it. Here is the check from the challenge:
await setCart(page, { notebook: 2, pens: 0 }); // $50.00
await expect(page.getByTestId('shipping')).toHaveText('Free');This kind of mistake has its own name, the off-by-one error: the rule says "50 or more" and the code says "more than 50", a difference of exactly one step at the edge.
How to use it
- List the limits from the requirements and from what a person can see: minimum and maximum quantities, text lengths, thresholds for a discount or free delivery, dates that start or end something.
- Pick three values for each: just below, on, and just above. For a quantity: 0, 1 and 2, or 99, 100 and 101 if the limit is 100.
- Test the invalid side too: negative numbers, an empty field, text where a number belongs, a number far too large.
- Turn the ones that found a bug into automated checks, so they run after every change. That is regression testing.
Boundaries in tools, not only in shops
The same habit applies to tools. The free website health check has edges of its own, and they are the kind a boundary test looks at: a page title of 60 characters passes and one of 61 gets a warning, a meta description of 170 passes and 171 warns, and an HSTS header of 15,552,000 seconds passes while 15,551,999 warns. The guide to title length lists them.
Questions people ask
How many values do I test for each boundary?
Three is the usual: just below, exactly on, and just above. If the boundary is between two inputs that are far apart, you can also test one typical value in the middle, but the edges are the point.
Does it work for text lengths and dates?
Yes. A password limit of 8 characters needs tests with 7, 8 and 9. A date range that starts on the first of the month needs the last day of the month before, the first day, and the second day.
Is it enough on its own?
No. It tells you which values to try, not which rules to look for. It works best next to ideas such as trying input of the wrong kind, and repeating an action that should happen only once, like the double-submit bug.