Updated March 17, 2023
Introduction to Equivalence Partitioning
Equivalence partitioning is a black box test design technique in which test cases are designed to execute representatives from equivalence partitions. It can be applied to any level of the software testing, designed to divide a sets of test conditions into the groups or sets that can be considered the same i.e. system should handle them equivalently. Equivalence partitioning is also known as equivalence classes.
How does Equivalence Partitioning Work?
This testing involved testing only for one condition for every partition which is created. The reason for this is that we consider that all conditions in one partition should be treated the same by the software. This is because we have an assumption that if one condition works for the partition, it will work for other conditions as well. This leaves us with saving our efforts in the testing. If a particular condition does not work, then it can be concluded that the other conditions will also not work and there is no point left in testing the other conditions in that partition. The partitions which are created can be created for valid data i.e for the values which can be accepted and also for invalid data which means values which are to be rejected. One representative value is chosen in the partition and it covers all the items in the same partition that can be considered. A set of data is to be chosen which can act as input condition. The result when the program is executed can classify as a set of equivalent data for that entire partition.
Examples of Equivalence Partitioning
Let us have a look at a few examples which will give us an idea on how the equivalence partitioning works.
Example #1
- Test cases for input box accepting alphabets from A to Z by using Equivalence Partitioning.
The test case should have all valid inputs for this partition. By this, we mean that pick nay alphabet between A to Z. If any other alphabet is chosen between these 26 alphabets the output will give us the same results. Hence we can conclude that one input is sufficient for testing this condition.
- Input data other than these alphabets account as invalid input. These inputs can be either numerical values or special characters.
By this, you can categorize and segregate all possible test cases which can be divided into three classes. Values in test cases other than the selected ones from any class should give the same result. There is one representative selected from every input class which helps us in designing the test cases. The test case values are selected in such a way that the largest number of values should be tested and the same results should be received for all test cases present in a class, This can be either for valid values or invalid values.
Example #2
A text field supports only numeric characters and their length should be 6 to 10 characters long. For this condition, there can be three partitions or classes which can be created. The first partition where numeric values are present having a length between 6 to 10. This is a valid condition. The second partition where numeric values are present but they have the length as 0 to 5. This is an invalid condition. The third partition having numeric values having a length from 11 to 14. This also is an invalid condition. While evaluating these partitions we can take cases from each of these partitions and test for all test cases present in these partitions. If we check one condition from each of these partitions all cases would be tested for each partition.
Example #3
Similar to previous examples, we can check data for decimal places as well. We can assume that we are considering either zero decimal places or more than two decimal places. When test cases are to be designed for this application, it should be ensured that all three partitions are covered. The invalid partition should be tested at least once. We can choose to calculate interest on the amount of Rs. -10.00, Rs. 50.00, Rs. 280 and Rs. 1354.00. If these were not mentioned specifically it is a possibility that one of them could be missed due to testing another several time. The partitioning can also be applied to outputs as well.
Importance of Equivalence Testing
Below are the important points for Equivalence Testing:
- Equivalence Testing is one of the effective ways of preparing test cases. It is a type of black-box testing which mainly focuses on testing the functionality of the software. Doing equivalence testing reduces the number of test cases. Also, it does not compromise on the test coverage of the software.
- The quality is not compromised, and effort is reduced due to partitions that are created. It is important as it saves time and one can work effortlessly on the generic test cases created for the partitions or classes. It is important for test cases that have a huge number of test cases and it is exhausting to test these.
- It also ensures the test coverage which needs to be maintained and taken care of. Once the test cases are created for valid and invalid inputs they can be tested, and the partitions will have similar results.
Conclusion
Equivalence Partitioning is a way in which data is partitioned and divided for efficient testing. The divided sets are known as partitions or classes. Dividing the data makes it easy to test and also reduces the number of test cases. This method increases the overall coverage of testing and ensures that black box testing is done in an effortless and efficient manner. Equivalence Partitioning is thus fast and if one condition in a partition passes then all conditions for that condition will be passed. Similarly, if one condition fails then collectively it will be failed for the entire partition. This technique can be used at all levels of testing and it can be ensured that a large number of test cases can be covered by dividing them into chunks.
Recommended Articles
This is a guide to Equivalence Partitioning. Here we discuss an introduction to Equivalence Partitioning, how does it work, with its examples and important. You can also go through our other related articles to learn more –