Software Engineering basics - Equivalence Partitioning

Definition

Equivalence Partitioning (also called Equivalence Class Partitioning, or ECP) is a black-box testing technique used to divide input data into groups (partitions) where all inputs in each group are expected to behave similarly — i.e., they should produce the same result from the software.

Instead of testing every possible input, we test one value from each partition, reducing the total number of test cases while maintaining coverage.


Purpose of Equivalence Partitioning

  • To minimize the number of test cases without losing test coverage.

  • To ensure that test inputs are representative of all possible values.

  • To identify invalid and valid input ranges.

  • To detect input handling errors efficiently.


Concept

Inputs are divided into:

  1. Valid Partitions → Inputs that should be accepted by the system.

  2. Invalid Partitions → Inputs that should be rejected or handled with an error.

Each partition is tested with one representative value.


Example

Scenario:

Suppose you have a program that accepts age as input.
The valid range for age is 18 to 60.

We can divide the input domain into equivalence classes:

Partition Type Input Range Example Test Value Expected Result
Invalid Age < 18 15 Rejected
Valid 18 ≤ Age ≤ 60 30 Accepted
Invalid Age > 60 75 Rejected

So instead of testing every possible number, we only test three representative values: 15, 30, and 75.


Diagram: Equivalence Partitioning

Here’s a simple conceptual diagram (text-based):

   ┌──────────────────────────────────────────────────────────┐
   │                   Input Domain (Age)                     │
   └──────────────────────────────────────────────────────────┘
   |<--------Invalid-------->|<----Valid---->|<-----Invalid---->|
   |        (<18)            | (18 - 60)     |     (>60)        |
   |   Example: 15 (Fail)    | 30 (Pass)     | 75 (Fail)        |
   └──────────────────────────────────────────────────────────┘

This shows how the input range is split into three partitions, and only one test case per partition is selected.


Steps in Equivalence Partitioning

Step Description
1 Identify input conditions (e.g., range, type, format).
2 Divide inputs into equivalence classes (valid and invalid).
3 Select one representative value from each class.
4 Design test cases using these representative values.
5 Execute tests and compare actual vs. expected results.

Advantages

  • Reduces total number of test cases.

  • Saves time and effort.

  • Provides good functional coverage with fewer tests.

  • Easy to apply and understand.


Disadvantages

  • Does not test all boundary values (that’s done using Boundary Value Analysis).

  • May miss defects at the edges of partitions.

  • Depends on correct identification of partitions.


Summary

Aspect Description
Testing Type Black-box testing
Focus Dividing input data into classes
Goal Reduce redundant tests while maintaining coverage
Used For Input range validation, form fields, data entry, etc.