Software Testing · Software Engineering

Equivalence Class Testing

Watch lectures

Equivalence Class Testing

Definition

Equivalence Class Partitioning (ECP) is a black-box test design technique that divides the input domain into partitions (classes) of data such that all values in a class are expected to be treated the same way by the program — then just one representative value from each class is tested, instead of every possible input.

Core Principle

If the program is expected to behave the same way for a whole range of inputs, testing one value from that range is (in theory) as effective as testing every value in it — massively reducing the number of test cases needed while still achieving good coverage.

Types of Equivalence Classes

Valid Equivalence Classes

Represent valid/acceptable inputs the system should process normally

Invalid Equivalence Classes

Represent invalid inputs the system should reject/handle with an error

Example

For an input field accepting age 1 to 100:

Class Range Type
Class 1 age < 1 Invalid
Class 2 1 ≤ age ≤ 100 Valid
Class 3 age > 100 Invalid

Test cases: pick one representative value from each class — e.g., -5 (Class 1), 50 (Class 2), 150 (Class 3) → only 3 test cases needed to cover all classes.

Guidelines for Identifying Classes

  • For a range [a, b]: one valid class (within range), two invalid classes (below a, above b)
  • For a set of specific valid values: one valid class per value (or group), one invalid class for anything else
  • For a Boolean condition: one valid class (true), one invalid class (false), or vice versa
  • For numeric values requiring specific handling (e.g., must be a member of a set): treat each meaningfully distinct case as its own class

Equivalence Class Testing vs. Boundary Value Analysis

Equivalence Class Testing Boundary Value Analysis
Tests one representative value per class Tests values specifically at boundaries
Assumes uniform behavior within a class Focuses on edge-case behavior
Fewer, broader test cases More targeted, boundary-specific test cases

In practice, both techniques are used together — BVA supplements ECP by specifically testing the edges of each equivalence class.

Advantages

  • Drastically reduces the number of test cases needed for large input domains
  • Systematic — ensures every logically distinct input scenario is covered at least once

Exam tip: Almost always paired with BVA — practice identifying valid/invalid equivalence classes for a given input range AND deriving boundary values from those same classes.

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.

← All Software Engineering modules