Boundary Value Analysis (BVA)
Boundary Value Analysis (BVA) is one of the most powerful test design techniques in software testing. It is based on the fact that bugs cluster at boundaries — the exact edges of valid and invalid input ranges. Instead of testing random values, BVA tells you exactly which values to test to maximize defect detection with minimum test cases.
The BVA Rule
- For any input range [min, max], always test these 5 values: min-1, min, min+1, max-1, max, max+1
- min-1: Just below the minimum — should be INVALID
- min: Exactly at the minimum — should be VALID
- min+1: Just above the minimum — should be VALID
- max-1: Just below the maximum — should be VALID
- max: Exactly at the maximum — should be VALID
- max+1: Just above the maximum — should be INVALID
- Why it works: Most boundary-related bugs are off-by-one errors (>= vs > mistakes in code). BVA targets exactly those points.
BVA Applied to Real Scenarios
// ══════════════════════════════════════════════════════════════
// SCENARIO 1: User age field (valid range: 18-65)
// ══════════════════════════════════════════════════════════════
// BVA Test Values: 17, 18, 19, 64, 65, 66
const ageTests = [
{ input: 17, expected: "INVALID", reason: "BVA: min-1 (below minimum)" },
{ input: 18, expected: "VALID", reason: "BVA: min (exact minimum)" },
{ input: 19, expected: "VALID", reason: "BVA: min+1 (just above minimum)" },
{ input: 64, expected: "VALID", reason: "BVA: max-1 (just below maximum)" },
{ input: 65, expected: "VALID", reason: "BVA: max (exact maximum)" },
{ input: 66, expected: "INVALID", reason: "BVA: max+1 (above maximum)" },
];
// Test implementation:
function validateAge(age) {
return age >= 18 && age <= 65;
}
ageTests.forEach(({ input, expected }) => {
const result = validateAge(input) ? "VALID" : "INVALID";
console.assert(result === expected, `Age ${input}: expected ${expected}, got ${result}`);
});
// ══════════════════════════════════════════════════════════════
// SCENARIO 2: Password length (valid: 8-20 characters)
// ══════════════════════════════════════════════════════════════
// BVA Test Values (character counts): 7, 8, 9, 19, 20, 21
const passwordLengthTests = [
{ len: 7, expected: false, note: "BVA: min-1 (too short)" },
{ len: 8, expected: true, note: "BVA: min (minimum valid)" },
{ len: 9, expected: true, note: "BVA: min+1 (just valid)" },
{ len: 19, expected: true, note: "BVA: max-1 (just under max)" },
{ len: 20, expected: true, note: "BVA: max (maximum valid)" },
{ len: 21, expected: false, note: "BVA: max+1 (too long)" },
];
function validatePasswordLength(pass) {
return pass.length >= 8 && pass.length <= 20;
}
// The off-by-one bug this catches:
// BAD code: if (age > 18) → rejects age=18 (valid boundary) ← BVA finds this
// BAD code: if (age <= 64) → rejects age=65 (valid boundary) ← BVA finds this
// ══════════════════════════════════════════════════════════════
// SCENARIO 3: E-commerce order quantity (valid: 1-99)
// ══════════════════════════════════════════════════════════════
// BVA values: 0, 1, 2, 98, 99, 100
// Test 0: Should reject (can't order 0 items)
// Test 1: Should accept (minimum order)
// Test 2: Should accept (min+1)
// Test 98: Should accept (max-1)
// Test 99: Should accept (maximum order without special approval)
// Test 100: Should reject or trigger manager approval workflowCommon Mistakes
- Only testing one boundary, not both — always test both the minimum AND maximum boundary with all 6 values
- Forgetting min-1 and max+1 (the invalid sides) — testing only inside the range misses off-by-one boundary errors
- Applying BVA to non-numeric ranges — BVA works on ordered ranges; for unordered inputs like dropdown selections, use EP instead
- Testing with the same internal value — avoid 'mid-range' values in BVA; EP handles those; BVA only targets boundaries
Tip
Tip
Practice Boundary Value Analysis BVA in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Boundary = most bugs found. Equivalence reduces test count. Decision tables for complex logic.
Practice Task
Note
Practice Task — (1) Write a working example of Boundary Value Analysis BVA from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Boundary Value Analysis BVA is skipping edge case testing — empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready software testing code.
Key Takeaways
- Boundary Value Analysis (BVA) is one of the most powerful test design techniques in software testing.
- For any input range [min, max], always test these 5 values: min-1, min, min+1, max-1, max, max+1
- min-1: Just below the minimum — should be INVALID
- min: Exactly at the minimum — should be VALID