Equivalence partitioning

Equivalence partitioning is a software test design technique that divides the possible inputs of a function or form into classes the software should treat the same way, then tests one representative value from each class. The assumption is that if one value in a class works, the others will too, which keeps the suite small.

The longer version

Take a field that accepts an age from 18 to 65. The inputs fall into three classes: values below 18, values from 18 to 65, and values above 65. Add non-numeric entries and an empty field and there are five. The tester picks one value from each, perhaps 12, 40, 80, a letter and nothing, and each run stands for every other value the software should handle identically. Five tests replace the hundreds that typing every number would take.

Both valid and invalid classes count. The valid ones confirm that good input is accepted and produces the right result; the invalid ones confirm that bad input is refused with a sensible message and without damage. The technique applies to outputs as well as inputs, to configuration states, and to anything else whose values group into sets with shared behaviour. A partition is only as good as the tester's reading of the rules, because a class that hides two behaviours yields a test that proves only one.

Defects cluster where one class meets another, at 17 and 18 or 65 and 66, and a single mid-class value never touches them. Boundary value analysis is therefore the usual companion: partitioning chooses the classes, and boundary testing adds the values on either side of each cut.

Grouping also helps whoever reports a failure. If a form rejects one value, finding which class it belongs to tells a developer how wide the fault is, one oddity or every value in that class, before anyone opens the code.

Common questions

What is equivalence partitioning in software testing?

A technique for choosing test inputs. The tester splits all possible inputs into groups that the software should handle identically, then runs one test per group. Because every value in a group is expected to behave the same, one representative stands in for all of them and the suite stays small.

How do you identify equivalence classes?

Read the rules that govern the input and mark every point where behaviour changes. A range gives one valid class and two invalid ones, a list of allowed values gives one class per value plus one for anything else, and a required field gives a filled class and an empty one. Each distinct behaviour is its own class.

What is the difference between equivalence partitioning and boundary value analysis?

Equivalence partitioning picks one value from inside each class. Boundary value analysis picks the values at and on either side of the edges between classes, where off-by-one mistakes concentrate. The two are normally used together, partitioning to find the classes and boundary analysis to probe their limits.

How many test cases does equivalence partitioning need?

One per equivalence class, valid and invalid. A field with a three-way range and two kinds of malformed input needs five. When several fields interact, the combinations multiply, and a combining technique such as pairwise testing is used to keep the total manageable.

Is equivalence partitioning black box testing?

Equivalence partitioning is a black box technique, since the classes come from the requirements and the rules the user sees, not from the code. The tester needs no access to the implementation. A white box tester can still use the same idea to group inputs by the code path they follow.

Bug reports that arrive ready to triage.

Collect replay, console, network and browser context with the Free plan.

<script src="…/widget.js" data-key="pb_pub_…">