Boundary Value Analysis: Technique, Examples and Test Cases
Most input bugs hide at the edges of a range, not in the middle. Learn boundary value analysis with a worked example, the exact values to test and code you can run.
- Boundary value analysis (BVA) tests the values at and next to the edges of an input range.
- For a valid range 18 to 60, test 17, 18, 19, 59, 60 and 61.
- Developers often make off-by-one errors with
<and<=, and mid-range values never catch them. - Use BVA together with equivalence partitioning to keep the test set small and strong.
Ask a developer to check “age must be between 18 and 60” and the code is usually right for 30 and 45. It breaks at 18 or 60, where one wrong comparison operator changes the result. Boundary value analysis exists to find exactly those bugs.
It is a black-box test design technique, so you need no access to the code, only the requirement. For a different way to design cases from rules, see our guide to decision table testing.
What boundary value analysis is
BVA is based on a simple observation: errors cluster at the boundaries of input ranges. Instead of testing many random values, you test the smallest and largest valid values and the values just outside them.
There are two common versions. Two-point BVA tests each boundary and the value just outside it. Three-point BVA adds the value just inside the boundary, which gives stronger coverage at a small cost.
A worked example: registration age
The requirement: users must be 18 to 60 years old to register. The valid range is 18 to 60, so the boundaries are 18 and 60.
| Input age | Position | Expected result |
|---|---|---|
| 17 | Just below the lower boundary | Rejected |
| 18 | Lower boundary | Accepted |
| 19 | Just above the lower boundary | Accepted |
| 59 | Just below the upper boundary | Accepted |
| 60 | Upper boundary | Accepted |
| 61 | Just above the upper boundary | Rejected |
Six cases cover the whole range. Testing 25, 30 and 45 would add almost no information.
Which values to pick
- Find the valid range and write down its minimum and maximum.
- Take the minimum and the maximum themselves.
- Take one step below the minimum and one step above the maximum. The step is 1 for whole numbers, 0.01 for money, one second for time.
- For three-point BVA, also take one step inside each boundary.
- Write the expected result for every value before you run it.
Tip: the “step” depends on the data type. For a price field that allows two decimals, the value just above 100.00 is 100.01, not 101.
Run it in Python
Here is the rule as code, with our six cases as checks. We ran this on Python 3.13, and every line passes.
def can_register(age):
return 18 <= age <= 60
cases = {17: False, 18: True, 19: True, 59: True, 60: True, 61: False}
for age, expected in cases.items():
assert can_register(age) == expected
print(age, can_register(age))
# 17 False
# 18 True
# 19 True
# 59 True
# 60 True
# 61 False
Now introduce the classic off-by-one bugs and see which tests catch them.
def buggy_lower(age):
return 18 < age <= 60 # should be >=
def buggy_upper(age):
return 18 <= age < 60 # should be <=
print([a for a in cases if buggy_lower(a) != cases[a]]) # [18]
print([a for a in cases if buggy_upper(a) != cases[a]]) # [60]
print([a for a in (25, 40) if buggy_lower(a) != can_register(a)]) # []
The first bug is caught only by 18, the second only by 60, and the mid-range ages 25 and 40 find nothing. That is the whole case for BVA in four lines.
Pair it with equivalence partitioning
Equivalence partitioning splits inputs into groups that the system should treat the same, such as “below 18”, “18 to 60” and “above 60”. BVA then picks the edge values of each group. Partitioning chooses the groups, BVA chooses the best values inside them. Put the resulting cases into the format from our guide on how to write test cases.
Where else boundary value analysis applies
- Text length: a username of 3 to 20 characters means testing 2, 3, 4, 19, 20 and 21 characters.
- Quantities and prices: minimum order, free-shipping thresholds, coupon limits.
- Dates and times: the first and last day of a month, midnight, leap days.
- Files and pages: maximum upload size, last page of a paginated list.
- APIs: limits, offsets and rate limits. Pair this with API testing with Postman.
Common mistakes
- Testing only the valid boundaries. The values just outside the range matter as much.
- Using the wrong step. A decimal field needs a decimal step.
- Trusting the UI alone. A form may block 61 while the API still accepts it. Test both layers.
- Forgetting hidden boundaries. Think of database column sizes and integer limits.
Final thoughts
Boundary value analysis is cheap, fast and effective. Write the six edge values for every range in your requirements and you will catch more bugs than a long list of random inputs.
Frequently asked questions
What is boundary value analysis in software testing?
It is a black-box test design technique that tests values at and around the edges of input ranges, because defects are most likely to appear there.
How many test cases does BVA need for one range?
Two-point BVA needs four values for a closed range, and three-point BVA needs six: below, on and above each boundary.
What is the difference between boundary value analysis and equivalence partitioning?
Equivalence partitioning divides inputs into groups that behave the same. Boundary value analysis picks the edge values of those groups, where bugs are most common.
Can BVA be used for non-numeric data?
Yes. Apply it to anything with an ordered limit, such as string length, dates, file size or list length.
Should I automate boundary tests?
Yes. They are small, deterministic and ideal for data-driven tests, so one test function can run many boundary values.
Keep learning
Need help with testing, WordPress or SEO?
We help teams ship better software and grow their sites. Tell us what you are working on and we will suggest a clear next step.