Course contentsShow
← Computer Science
Lesson 2221 of 2,87250. Software TestingFree lesson

Equivalence Partitioning

Dividing input domains into equivalence classes to reduce the number of test cases needed.

Equivalence Partitioning

What you'll learn: How to drastically reduce the number of test cases you need by grouping similar inputs into equivalence classes.

The Core Idea

When testing software, you can't test every possible input—there are simply too many. Equivalence Partitioning is a black box testing technique that divides all possible inputs into groups (partitions) where each member of a group should behave the same way. You then pick just one representative from each group to test, dramatically reducing your test suite size while maintaining confidence.

How It Works

Imagine testing a function that accepts ages 18-65 for job applications. Instead of testing all 48 values, you identify three equivalence classes:

  1. Valid inputs (18-65): Test with one value, say 30
  2. Too low (< 18): Test with one value, say 10
  3. Too high (> 65): Test with one value, say 70

The assumption: if the system handles 30 correctly, it should handle 25, 42, and 63 the same way. If it rejects 10, it should reject 5 and 15 similarly.

Why It Matters

This technique directly builds on code coverage metrics you've learned—you're strategically selecting test cases that explore different code paths without redundancy. You're applying the principle of black box testing: you don't care how the code works internally, just that each class of input produces the expected behavior.

Think of it like taste-testing soup: you don't need to sample every spoonful to know if it's salty. One spoonful from a well-stirred pot represents the whole batch.

Key Takeaway: Equivalence Partitioning reduces test case explosion by grouping inputs that should produce similar behavior and testing only one representative per group, maximizing efficiency while maintaining thorough coverage.