What Is Equivalence Partitioning?

Sher Hassan
BITLogix
3 min readJan 31, 2022

--

This is the sixth article in the series of our articles about test cases. In this article, we discuss the Equivalence Partitioning test case design method with simple examples for easy understanding.

Equivalence Partitioning is a test case design method in Black-Box Testing. It is used to divide the domain of all the inputs into a set of equivalence classes of data from which test cases can be designed. These classes of data are sometimes called equivalence partitions or domains. The test cases are designed so that the inputs or outputs lie within these partitions. However, without looking at the program’s internal structure, it is impossible to determine such ideal equivalence classes.

An equivalence class represents a set of valid or invalid states for the input conditions. The input condition may be a specific numeric value, a range of values, a set of related values, or a Boolean condition. Equivalence classes may be defined to the following guidelines:

1. If an input condition specifies a range or a specific value, one valid and two invalid equivalence classes are defined.

2. If an input condition specifies a Boolean condition, one valid and one invalid equivalence class are defined.

Equivalence classes are usually formed by considering each condition specified on input as specifying a valid equivalence class and one or more invalid equivalence classes.

Example1:

If an input condition specifies a range of values (e.g. 100<S<200), then form a valid equivalence class with that range and also two invalid equivalence classes, one with values less than the lower bound of range (i.e. S<100) and the other with values greater than the higher bound (i.e. S>200). The following figure shows the equivalence class for input values of “S”.

Example2:

If you are testing for an input box accepting numbers from 1 to 500 then there is no use in writing hundreds of test cases for all 500 valid input numbers plus other test cases for invalid data.

Using the Equivalence Partitioning method above, test cases can be divided into three sets of input data called classes. Each test case is representative of the respective class.

So in the above example, we can divide our test cases into three equivalence classes of some valid and invalid inputs.

Test cases for input box accepting numbers between 1 and 500 using Equivalence Partitioning:

We will get the following three classes (One Valid class and Two Invalid classes)

1. Valid Class: All numbers between 1 and 500. Pick any number between 1 and 500 results will be the same for all.

2. Invalid Class 1: Pick any number which is less than 1 (means negative number). Results will be the same for all.

3. Invalid Class 2: Pick any number which is greater than 500. Results will be the same for all.

We have selected one representative from each input class to design our test cases. Test case values are selected in such a way that the largest number of attributes of the equivalence class can be exercised. the Equivalence Partitioning uses the fewest test cases to cover the maximum requirements.

The equivalence classes can also be considered for the output. For an output equivalence class, the goal is to generate test cases such that the output for that test case lies in the output equivalence class. It is a somehow difficult task, but output classes have been found to see errors that are not traced out by input classes.

In a nutshell, we can say that Equivalence Partitioning is the test case design method in which we take all possible test cases and place them into classes. One test value is picked from each class while testing. In our next article, we will discuss Boundary Value Analysis. Stay tuned with us and if you have any questions and queries please feel free to ask in the comments.

--

--

Sher Hassan
BITLogix

Software Quality Assurance/Control ||Business Analysis || Research || Blog/Content Writing