# Equivalence Partitioning

Equivalence partitioning is a test case selection technique for black box testing. In this method, testers identify various classes of input conditions called as equivalence classes. These classes are identified such that each member of the class causes the same kind of processing and output to occur.

Basically, a class is a set of input conditions that are similar in nature for a system. In this test case selection technique, it is assumed that if the system will handle one case in the class erroneously, it would handle all cases erroneously.

This technique drastically cuts down the number of test cases required to test a system reasonably. Using this technique, one can found the most errors with the smallest number of test cases.

To use equivalence partitioning, you will need to:

• Determining conditions to be tested
• Defining and designing tests

Determining conditions to be tested:

1. All valid input data for a given condition are likely to go through the same process.
2. Invalid data can go through various processes and need to be evaluated more carefully. For example:
• Treat the blank entry differently than an incorrect entry.
• Treat a value differently if it is less than or greater than a range of values.
• If there are multiple error conditions within a function, one error may override the other, which means that the subordinate error does not get tested unless the other value is valid.

Defining and Designing Test Cases:

• First, include valid tests and include as many valid tests as possible in one test case.
• For invalid input, include only one test in a test case in order to isolate the error.

Example: In a company, first three digits of all employee IDs, the minimum number is 333 and the maximum number is 444. For the fourth and fifth digits, the minimum number is 11 and the maximum number is 99.
So, for the first three digits the various test conditions can be

a. = or > 333 and = or <>
b. <>
c. > 444, (invalid input, above the range)
d. Blank, (invalid input, below the range).
And for the third and fourth digits the various test conditions can be
e. = or > 11 and = or <>
f. <>
g. > 99, (invalid input, above the range)
h. blank, (invalid input, below the range)

Now, while using equivalence partitioning; only one value that represents each of the eight equivalence classes needs to be tested.

Now, after identifying the tests, you will need to create test cases to test each equivalence class. Create one test case for the valid input conditions and identify separate test cases for each invalid input.

As a black box tester, you might not know the manner in which the programmer has coded the error handling. So, you will need to create separate tests for each invalid input, to avoid masking the result in the event one error takes priority over another.

Thus, based on the test conditions, there can be seven test cases:

• Test case for a and e – (both are valid)
• Test case for b and e – (only the first one is invalid)
• Test case for c and e – (only the first one is invalid)
• Test case for d and e – (only the first one is invalid)
• Test case for a and f – (only the second one is invalid)
• Test case for a and g – (only the second one is invalid)
• Test case for a and h – (only the second one is invalid)

Also See:

##### Rahnuma Tasnim

Rahnuma is a technical content writer at software testing stuff. A software engineer by degree and a dynamic content creator by passion, she brings to table over 3 years of writing experience in tech niche. Combining her enthusiasm for writing and technology, she loves to share her thoughts on the latest tech trends.