Equivalence partitioning and boundary value analysis in Software Engineering - Time & Space Complexity
When studying equivalence partitioning and boundary value analysis, it is important to understand how these techniques reduce the number of test cases compared to exhaustive testing.
We want to know how test case count grows relative to the input domain size.
Compare exhaustive testing versus partition-based testing for a function with a defined input range.
Exhaustive testing:
for each value in input_domain: -- O(n)
run test(value)
Partition + Boundary testing:
partitions = split_into_classes(input_domain) -- O(1)
for each partition in partitions: -- O(p)
test one representative value
for each boundary in boundaries: -- O(b)
test boundary value
Exhaustive testing checks every possible value. Partition and boundary testing checks a fixed number of carefully selected values.
Look at what scales in each approach.
- Exhaustive: The test loop runs once per possible input value. For age 1-120, that is 120 tests for valid inputs alone.
- Partition + Boundary: The number of partitions (p) and boundaries (b) is determined by the specification, not the range size. Doubling the range does not double the tests.
As the valid range grows, exhaustive testing grows linearly but partition testing stays constant.
| Valid Range Size (n) | Exhaustive Tests | EP + BVA Tests |
|---|---|---|
| 10 (age 1-10) | 10+ | 9 (3 partition + 6 boundary) |
| 120 (age 1-120) | 120+ | 9 |
| 10,000 (ID 1-10000) | 10,000+ | 9 |
Pattern observation: EP + BVA test count depends on the number of partitions and boundaries, not the range size. It is essentially O(1) relative to domain size.
Exhaustive Testing: O(n) where n is the domain size
EP + BVA: O(p + b) where p is partitions and b is boundary values — typically constant for a given specification
This is why EP and BVA are standard techniques: they provide strong defect detection with a fixed, small number of tests regardless of input range size.
[X] Wrong: "More test cases always means better testing."
[OK] Correct: Testing age=25 and age=50 both exercise the same valid partition. The second test adds time but no additional defect detection. EP and BVA maximize coverage per test case by selecting values that represent distinct behaviors.
EP and BVA are among the most commonly asked testing techniques in QA and SDET interviews. Being able to derive a test set from a specification and explain why each value was chosen demonstrates strong testing fundamentals.
A function accepts a discount percentage from 0 to 100. How many equivalence partitions exist? What are the boundary values you would test?