Key takeaways
- A boundary is where one behaviour ends and another starts: 49 → 50, 100 → 101, 31 December → 1 January.
- Developers often make off-by-one mistakes there, such as
>instead of>=. So bugs cluster at boundaries. - Boundary value analysis tests the value on each boundary and the value just beyond it.
Why edges?
When a developer writes "50 or more", the code might say score >= 50. Or, by mistake, score > 50. Both work for 30 and for 75. Only 50 shows the difference.
That's the logic of boundary value analysis: test where a small slip in the code changes the result. Values in the middle of a range rarely reveal these mistakes.
How it works
Start with equivalence partitions. An exam app accepts scores from 0 to 100, and 50 or more passes:
| Partition | Range |
|---|---|
| Invalid (too low) | below 0 |
| Fail | 0–49 |
| Pass | 50–100 |
| Invalid (too high) | above 100 |
The boundaries are the minimum and maximum of each partition: 0 and 49, 50 and 100. Each sits next to a neighbour in another partition: -1, 101.
Two-value boundary testing
For each boundary, test the boundary value and its closest neighbour in the next partition:
| Edge | Values to test | Expected |
|---|---|---|
| Lower limit | -1, 0 | Rejected, Fail |
| Fail → Pass | 49, 50 | Fail, Pass |
| Upper limit | 100, 101 | Pass, Rejected |
Six tests that would catch every common off-by-one mistake in this rule.
Three-value boundary testing
For riskier areas, also test the value just inside the boundary. For the pass mark, that means 49, 50 and 51. It catches mistakes like score == 50 where score >= 50 was meant.
Boundaries are everywhere
Not just in number fields. Look for limits in:
- Lengths: a name of 1 and 50 characters, and 0 and 51.
- Dates and times: end of month, 29 February, midnight, the switch to summer time, 31 December.
- Money: a free-shipping threshold, a credit limit, a discount tier.
- Quantities: an empty cart, the maximum items per order.
- Sizes: the largest allowed upload, and a file one byte bigger.
A boundary that froze thousands of devices
On 31 December 2008, Microsoft's 30 GB Zune music players, the 2006 model, froze at startup, around the world, all at once.
Microsoft explained that a bug in the device's clock driver mishandled the last day of a leap year. 2008 was a leap year, so 31 December was day 366. According to widely shared analyses of the driver code, a loop that converted days into years didn't handle that exact value, and kept running forever.
Microsoft's workaround: let the battery run down and restart the player after the new year. On 1 January, the devices worked again.
Lesson: the code worked for 365 days a year, and for 365 of the 366 days in a leap year. A single boundary value, day 366, broke it. That's exactly the kind of value boundary analysis tells you to test.
Step by step
- Find the partitions for the input, valid and invalid.
- Mark each boundary: the lowest and highest value of each partition.
- Pick the values: each boundary plus its neighbour in the next partition. Add the inside neighbour for risky areas.
- Write the expected result for each value, from the requirement.
- Check the requirement's wording. "Up to 10", "more than 10", "at least 10": each puts the boundary in a different place. If it's unclear, ask.
Do
Ask exactly where a limit is: "Does a discount 'for orders over 200' apply at exactly 200?" The answer often surprises the team.
Don't
Test only 'nice' values like 100, 500 and 1,000. They're far from the edges where off-by-one mistakes hide.
For a more advanced worked example combining both techniques, see Equivalence partitioning and boundary values: beyond the basics.
Check yourself
A field accepts quantities from 1 to 10. Using two-value boundary testing, which values do you test?
Show answer
0, 1, 10 and 11. 0 and 11 should be rejected; 1 and 10 should be accepted. With three-value testing you'd add 2 and 9.
