Beyond Single-Variable Boundaries
Boundary value analysis (Lesson 3.2) tests one variable at a time. But real software has input spaces defined by relationships between multiple variables. Consider a loan approval system:
- Approved if:
income >= 30000 AND debt_ratio < 0.4 AND credit_score >= 650
This creates a three-dimensional input domain. The boundary is not a single point but a surface in 3D space. Testing each variable independently (as BVA does) misses defects that occur at the intersection of boundaries.
Domain analysis, formalized by Beizer and later by Binder, extends BVA to handle these multi-dimensional input spaces systematically.
Core Concepts
Input Domain
The set of all possible input combinations. For two integer variables x (1-100) and y (1-50), the domain is a 100 x 50 rectangle in 2D space.
Domain Boundary
A boundary is a condition that divides the input space into regions with different behaviors. x + y <= 100 creates a diagonal line in 2D space — inputs on one side are accepted, inputs on the other are rejected.
On Points and Off Points
On point: A value that lies exactly on the boundary.
- For
x <= 10: on point is x = 10 - For
x < 10: on point is x = 10 (the boundary itself, even though 10 is excluded)
Off point: A value that is minimally different from the on point, on the other side of the boundary.
- For
x <= 10(closed boundary): off point is x = 11 - For
x < 10(open boundary): off point is x = 10 (since 10 is just outside the domain)
Wait — this seems confusing. Let us clarify with a precise rule:
For a boundary condition where the domain is on one side:
- On point: Exactly on the boundary, on the domain side (IN the domain if closed, OUT if open)
- Off point: Minimally across the boundary from the on point
| Boundary | On Point | Off Point |
|---|---|---|
| x <= 10 (domain is x <= 10) | 10 (in domain) | 11 (out) |
| x < 10 (domain is x < 10) | 9 (in domain) | 10 (out) |
| x >= 5 (domain is x >= 5) | 5 (in domain) | 4 (out) |
| x > 5 (domain is x > 5) | 6 (in domain) | 5 (out) |
In Points
Values clearly inside the domain — not near any boundary. Used to verify that the interior of the domain behaves correctly.
Out Points
Values clearly outside the domain — not near any boundary. Used to verify rejection behavior.
Domain Error Types
Boundary Shift
The boundary is at the wrong position. The condition should be x <= 100 but is implemented as x <= 99 or x <= 101.
Closure Error
The boundary has the wrong type. Should be x <= 10 but implemented as x < 10, or vice versa. The boundary position is correct but the inclusion/exclusion is wrong.
Missing Boundary
A boundary that should exist is absent. The specification says “discount applies only to orders over $50” but no check for $50 is implemented.
Extra Boundary
A boundary exists that should not. An unnecessary validation rejects valid inputs.
Tilted Boundary
For multi-variable boundaries like x + y <= 100, the boundary has the wrong slope. Implemented as x + 2*y <= 100 instead.
The Domain Analysis Method
Step 1: Identify Variables and Boundaries
List all input variables and the conditions that define boundaries between different behaviors.
Example: Insurance Quote
- Variables: age (18-80), driving_years (0-62), accidents (0-10)
- Boundaries: age >= 25, driving_years >= 3, accidents <= 2 → standard rate
Step 2: For Each Boundary, Select On and Off Points
| Boundary | Variable | On Point | Off Point |
|---|---|---|---|
| age >= 25 | age | 25 | 24 |
| driving_years >= 3 | driving_years | 3 | 2 |
| accidents <= 2 | accidents | 2 | 3 |
Step 3: Build the Domain Matrix
Each test case varies one boundary while keeping others at typical (interior) values:
| Test | age | driving_years | accidents | Boundary Tested | Expected |
|---|---|---|---|---|---|
| 1 | 25 | 10 | 0 | age ON | Standard |
| 2 | 24 | 10 | 0 | age OFF | Higher rate |
| 3 | 35 | 3 | 0 | years ON | Standard |
| 4 | 35 | 2 | 0 | years OFF | Higher rate |
| 5 | 35 | 10 | 2 | accidents ON | Standard |
| 6 | 35 | 10 | 3 | accidents OFF | Higher rate |
| 7 | 35 | 10 | 0 | IN point | Standard |
This requires 2 tests per boundary plus 1 in-point = 2B + 1 total.
Multi-Variable Boundaries
When boundaries involve multiple variables, the analysis becomes more interesting.
Example: Free shipping if quantity * price >= 100
This is a linear boundary in 2D space. On points lie exactly on the line quantity * price = 100:
- (10, 10), (20, 5), (50, 2), (100, 1)
Off points are just below:
- (10, 9.99), (20, 4.99), (50, 1.99)
Test at multiple on/off point pairs along the boundary to detect tilted boundary errors.
Exercise: Domain Analysis
Problem 1
A parking rate calculator uses these rules:
- First hour: $5.00
- Hours 2-4: $3.00/hour
- Hours 5-8: $2.00/hour
- Hours 9-24: $1.50/hour
- Over 24 hours: $1.00/hour
Maximum charge: $50/day
Apply domain analysis to identify boundaries and derive test cases.
Solution
Variables: duration (hours), continuous from 0
Boundaries:
| # | Boundary | On Point | Off Point |
|---|---|---|---|
| 1 | duration = 1 | 1.0 | 1.01 (enters hour 2 rate) |
| 2 | duration = 4 | 4.0 | 4.01 (enters hour 5 rate) |
| 3 | duration = 8 | 8.0 | 8.01 (enters hour 9 rate) |
| 4 | duration = 24 | 24.0 | 24.01 (enters over-24 rate) |
| 5 | max charge = $50 | at cap | just over cap |
Test cases:
| # | duration | Expected Cost | Tests |
|---|---|---|---|
| 1 | 0.5 | $5.00 | IN point, first hour |
| 2 | 1.0 | $5.00 | ON boundary 1 |
| 3 | 1.01 | $5.00 + $0.03 | OFF boundary 1 |
| 4 | 4.0 | $5 + 3*3 = $14.00 | ON boundary 2 |
| 5 | 4.01 | $14.00 + $0.02 | OFF boundary 2 |
| 6 | 8.0 | $14 + 4*2 = $22.00 | ON boundary 3 |
| 7 | 8.01 | $22.00 + $0.015 | OFF boundary 3 |
| 8 | 24.0 | $22 + 16*1.5 = $46.00 | ON boundary 4 |
| 9 | 24.01 | $46 + $0.01 | OFF boundary 4 |
| 10 | 48 | $50.00 (capped) | Max charge boundary |
Problem 2
A fitness app categorizes users by two variables:
- BMI: underweight (<18.5), normal (18.5-24.9), overweight (25-29.9), obese (>=30)
- Activity level: sedentary (<150 min/week), moderate (150-300), active (>300)
The app recommends different programs based on the BMI-activity combination. Apply domain analysis to the BMI x activity 2D space.
Solution
Boundaries:
| # | Variable | Boundary | On | Off |
|---|---|---|---|---|
| 1 | BMI | 18.5 | 18.5 | 18.4 |
| 2 | BMI | 25.0 | 24.9 | 25.0 |
| 3 | BMI | 30.0 | 29.9 | 30.0 |
| 4 | Activity | 150 | 150 | 149 |
| 5 | Activity | 300 | 300 | 301 |
Domain matrix (12 regions = 4 BMI x 3 activity):
| # | BMI | Activity | Category |
|---|---|---|---|
| 1 | 18.4 | 100 | Underweight + Sedentary |
| 2 | 18.5 | 100 | Normal + Sedentary (ON BMI boundary) |
| 3 | 22.0 | 149 | Normal + Sedentary (OFF activity boundary) |
| 4 | 22.0 | 150 | Normal + Moderate (ON activity boundary) |
| 5 | 22.0 | 225 | Normal + Moderate (IN point) |
| 6 | 22.0 | 300 | Normal + Moderate (ON boundary) |
| 7 | 22.0 | 301 | Normal + Active (OFF boundary) |
| 8 | 24.9 | 225 | Normal + Moderate (ON BMI boundary) |
| 9 | 25.0 | 225 | Overweight + Moderate (OFF BMI boundary) |
| 10 | 29.9 | 225 | Overweight + Moderate (ON BMI boundary) |
| 11 | 30.0 | 225 | Obese + Moderate (OFF BMI boundary) |
| 12 | 35.0 | 400 | Obese + Active (OUT point) |
This gives comprehensive boundary coverage across the 2D input space.
When to Use Domain Analysis
Use domain analysis when:
- Multiple input variables interact to determine behavior
- Boundaries involve relationships between variables (x + y > limit)
- The specification defines ranges or categories for inputs
- You need to detect off-by-one, closure, and boundary shift errors
Prefer simpler BVA when:
- Variables are independent (no interactions)
- Single-variable boundaries are sufficient
- Time constraints require a lighter approach
Key Takeaways
- Domain analysis extends BVA to multi-variable input spaces
- On points sit exactly on boundaries; off points are minimally across
- Test 2 points per boundary (on + off) plus interior points = 2B + 1 minimum
- Four error types: boundary shift, closure, missing boundary, tilted boundary
- Build domain matrices to systematically vary one boundary while holding others at interior values
- For multi-variable boundaries (x + y = C), test multiple on/off pairs to detect tilt errors
- Domain analysis is most valuable when variables interact to define acceptance regions