Equivalence Partitioning
Learn equivalence partitioning to reduce test cases while maintaining coverage
35 min•By Priygop Team•Last updated: Feb 2026
Equivalence Partitioning Principles
- Divide input data into equivalent groups
- All values in a partition behave similarly
- Test one value from each partition
- Reduces number of test cases
- Maintains test coverage
Equivalence Partitioning Examples
Example
// Example: Age validation (18-65)
function testAgeEquivalencePartitions() {
// Valid partition: 18-65
// Invalid partitions: <18, >65, non-numeric
// Test one value from valid partition
expect(validateAge(25)).toBe(true); // Representative of 18-65
// Test one value from each invalid partition
expect(validateAge(17)).toBe(false); // Representative of <18
expect(validateAge(66)).toBe(false); // Representative of >65
expect(validateAge("abc")).toBe(false); // Representative of non-numeric
}
// Example: Grade calculation
function testGradeEquivalencePartitions() {
// A: 90-100
// B: 80-89
// C: 70-79
// D: 60-69
// F: 0-59
// Invalid: <0, >100, non-numeric
// Test one value from each valid partition
expect(getGrade(95)).toBe('A'); // Representative of 90-100
expect(getGrade(85)).toBe('B'); // Representative of 80-89
expect(getGrade(75)).toBe('C'); // Representative of 70-79
expect(getGrade(65)).toBe('D'); // Representative of 60-69
expect(getGrade(55)).toBe('F'); // Representative of 0-59
// Test invalid partitions
expect(getGrade(-5)).toBe('Invalid'); // Representative of <0
expect(getGrade(105)).toBe('Invalid'); // Representative of >100
expect(getGrade("abc")).toBe('Invalid'); // Representative of non-numeric
}
// Example: Email validation
function testEmailEquivalencePartitions() {
// Valid: proper email format
// Invalid: missing @, missing domain, missing username, etc.
// Test valid partition
expect(validateEmail("user@example.com")).toBe(true);
// Test invalid partitions
expect(validateEmail("userexample.com")).toBe(false); // Missing @
expect(validateEmail("@example.com")).toBe(false); // Missing username
expect(validateEmail("user@")).toBe(false); // Missing domain
expect(validateEmail("user@example")).toBe(false); // Missing TLD
expect(validateEmail("")).toBe(false); // Empty string
}Try It Yourself — Manual Testing Techniques
Try It Yourself — Manual Testing TechniquesHTML
HTML Editor
✓ ValidTab = 2 spaces
HTML|32 lines|1605 chars|✓ Valid syntax
UTF-8