Skip to main content

Equivalence partitioning: telephone numbers

Short answer

Equivalence partitioning divides inputs into valid and invalid classes expected to behave alike, testing one representative from each class. For a 10-digit Pumpkin Republic number: valid classes are 10 digits, all digits, district 01-85, and service digit 1 or 2; invalid classes cover wrong length, non-digits, district 00 or 86-99, and service 0 or 3-9.

What is Equivalence Partitioning? Explain with an example of checking for a telephone number (of a Country called Pumpkin Republic, which has 85 districts altogether) entry like 4422561263, where first two digits signify the number of district, third digit for either PSTN (1) or Cellular (2) and remaining digits are just numbers.

Equivalence partitioning is a black-box testing technique that divides the input domain into equivalence classes. All values in one class are expected to be handled the same way by the program, so one test value from each class is enough. Classes are made for valid and invalid inputs. This reduces the number of test cases while still covering the input domain.

Example: Pumpkin Republic telephone number

Format of 4422561263 (10 digits):

  4 4   |   2    |  2 5 6 1 2 6 3
District| Service| Subscriber number
 (01-85)| 1=PSTN | (7 digits, 0-9)
        | 2=Cell |

Assumptions: exactly 10 digits; districts 1–9 written as 01–09; the last 7 digits may be any digits.

Equivalence classes

ConditionValid classesInvalid classes
LengthV1: exactly 10I1: fewer than 10; I2: more than 10
CharactersV2: all digitsI3: contains letter/symbol/space
District (digits 1–2)V3: 01 to 85I4: 00; I5: 86 to 99
Service (digit 3)V4: 1 (PSTN); V5: 2 (Cellular)I6: 0 or 3 to 9

Test cases (one invalid class per invalid test, so the cause of rejection is clear)

No.InputClasses coveredExpected
14422561263V1, V2, V3, V5Valid (cellular)
24412561263V1, V2, V3, V4Valid (PSTN)
3442256126I1Invalid length
444225612634I2Invalid length
544225A1263I3Invalid character
60012561263I4Invalid district
79022561263I5Invalid district
84452561263I6Invalid service code

Adding boundary values of the district class (01, 85 valid; 00, 86 invalid), e.g. 0112345678, 8522345678 and 8612345678, makes the test set stronger.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Software Engineering chapter 8 questions →