Skip to main content
Beginner reading +15 XP

Boundary Value Analysis

Boundary value analysis sounds boring until it catches a bug that would have cost your company real money. Here's how it works, and why bugs love to hang out at the edges.

Where Bugs Live

Think about the age field from the last lesson (valid range: 18-65). Equivalence partitioning told us to test one value from each group. But which value?

Experience shows that bugs cluster at boundaries — the edges where one behavior switches to another. Off-by-one errors are among the most common bugs in software. A developer writes if (age > 18) when they meant if (age >= 18), and suddenly 18-year-olds can't register.

The Technique

For every boundary, test:
- The value just below the boundary
- The boundary itself
- The value just above the boundary

For our age field (18-65):

Test Value Why
17 Just below the lower boundary
18 The lower boundary itself
19 Just above the lower boundary
64 Just below the upper boundary
65 The upper boundary itself
66 Just above the upper boundary

Six tests that are far more likely to find bugs than testing random values like 30, 40, 50.

Combining with Equivalence Partitioning

These two techniques work together. Equivalence partitioning tells you which groups to test. Boundary value analysis tells you which values within those groups are most likely to reveal bugs.

Together, they give you maximum coverage with minimum effort.

Real-World Examples

Shopping cart quantity (1-99): Test 0, 1, 2, 98, 99, 100. The boundaries at 0→1 and 99→100 are where the discount logic, shipping calculation, or stock validation is most likely to break.

Date fields: February 28th vs 29th (leap year), December 31st vs January 1st, month boundaries. Date arithmetic is notoriously buggy.

String length (max 255 characters): Test 254, 255, and 256. Database column overflows are a classic boundary bug.

Exercise

A flight booking system offers these fare classes based on how many days before departure you book:
- 0-7 days: Premium fare ($500)
- 8-21 days: Standard fare ($300)
- 22+ days: Early bird fare ($200)

List all the boundary values you'd test and the expected fare for each.

The key takeaway: Bugs love boundaries. Test the edges first, the middle later.

Exercise Multiple Choice

A shopping cart allows quantities from 1 to 99. Which set of boundary values should you test?

Exercise Flashcard

Why do bugs cluster at boundary values?

Click to reveal answer

Exercise Multiple Choice

A flight booking system charges Early Bird fare for bookings made 22+ days before departure. Which boundary values would test the transition between Standard and Early Bird fares?