4.3 Boundary Value Analysis
Key Takeaways
- Boundary value analysis focuses on values at and near the edges of ordered partitions.
- Defects often occur at boundaries because of comparison and off-by-one errors.
- Two-value BVA tests the boundary value and the nearest value across the boundary.
- Three-value BVA tests before, at, and after each boundary.
- BVA is usually used with equivalence partitioning.
Why Boundaries Matter
Boundary value analysis, or BVA, is based on a simple observation: defects often appear at the edges of ranges. Developers may use less than instead of less than or equal to. A loop may stop one value too early. Validation may accept the largest valid value but fail one step below it.
BVA applies to ordered partitions. The order may be numeric, date based, count based, size based, or ranked. It does not fit unordered categories such as blue, green, and red unless there is a defined ordering.
BVA is normally performed after equivalence partitioning. EP identifies the partitions. BVA then focuses on the borders between adjacent partitions.
Two-Value BVA
Two-value BVA uses two values around each boundary. For a boundary between invalid and valid values, select the boundary value and the closest value on the other side.
Requirement: A quantity field accepts integers from 1 through 10 inclusive.
Partitions are less than 1, 1 through 10, and greater than 10. The boundaries are 1 and 10.
Two-value BVA test values:
| Boundary | Values | Why |
|---|---|---|
| Lower boundary 1 | 0, 1 | Closest invalid and boundary valid |
| Upper boundary 10 | 10, 11 | Boundary valid and closest invalid |
The two-value BVA set is 0, 1, 10, and 11.
Three-Value BVA
Three-value BVA uses the value before, the boundary value, and the value after each boundary. It gives stronger edge coverage, especially when off-by-one defects are likely.
For the same 1 through 10 requirement:
| Boundary | Values |
|---|---|
| Lower boundary 1 | 0, 1, 2 |
| Upper boundary 10 | 9, 10, 11 |
The three-value BVA set is 0, 1, 2, 9, 10, and 11.
Exclusive Boundary Example
Requirement: A temperature alert is active when temperature is greater than 100.0 degrees. Assume one decimal place precision.
The behavioral boundary is between 100.0 and 100.1. The value 100.0 is not in the active partition because the rule says greater than 100.0.
Two-value BVA values are 100.0 and 100.1. Three-value BVA values may include 99.9, 100.0, and 100.1 around that change point.
This is where exam questions often become tricky. Always read whether the boundary is inclusive or exclusive. Phrases such as at least, no more than, from X through Y, greater than, and less than determine which side contains the boundary value.
Date Example
Requirement: A coupon is valid from May 1 through May 31, inclusive.
Two-value BVA around the lower boundary: April 30 and May 1. Around the upper boundary: May 31 and June 1.
Three-value BVA adds May 2 and May 30. The set becomes April 30, May 1, May 2, May 30, May 31, and June 1.
Coverage Measurement
Boundary coverage is measured as covered boundary values divided by total identified boundary values.
If three-value BVA for a range identifies 6 boundary values and your suite covers 4 of them, BVA coverage is 4 / 6 = 66.7 percent.
Practical Notes
BVA is strongest when data is discrete or has clear precision. For currency, define cents. For dates, define days or timestamps. For character limits, define number of characters and decide whether spaces, Unicode, or hidden characters count.
BVA should not replace normal in-range testing. A value in the middle of a valid partition is still useful to show ordinary behavior. Boundary tests show behavior at the edges.
A field accepts integer scores from 50 through 100 inclusive. What are the two-value BVA values?
For an inclusive integer range from 3 through 7, what is the three-value BVA set?