What is "Equivalence Class Partitioning"? We define "Equivalence Class Partitioning" as a method that can help you derive test cases. You identify classes of input or output conditions. The rule is that each member in the class causes the same kind of behavior of the system. In other words, the "Equivalence Class Partitioning" method creates sets of inputs or outputs that are handled in the same way by the application. Another definition taken from Wikipedia: "A technique in black box testing. It is designed to minimize the number of test cases by dividing tests in such a way that the system is expected to act the same way for all tests of each equivalence partition. Test inputs are selected from each class. Every possible input belongs to one and only one equivalence partition." Why learn "Equivalence Class Partitioning"? This method drastically reduces the number of test cases that are required to be tested because we don't have time, money or manpower to test everything. In addition, it can help you find many errors with the smallest number of test cases. How to use "Equivalence Class Partitioning"? There are 2 major steps we need to do in order to use equivalence class partitioning:
Example 1 In a computer store, the computer item can have a quantity between -500 to +500. What are the equivalence classes? Answer: Valid class: -500 <= QTY <= +500 Invalid class: QTY > +500 Invalid class: QTY < -500 Example 2 In a computer store, the computer item type can be P2, P3, P4, and P5 (each type influences the price). What are the equivalence classes? Answer: Valid class: type is P2 Valid class: type is P3 Valid class: type is P4 Valid class: type is P5 Invalid class: type isn’t P2, P3, P4 or P5 Practice Bank account can be 500 to 1000 or 0 to 499 or 2000 (the field type is integer). What are the equivalence classes? Try to solve it before reading the answer. Practice 1 - answer
Equivalence Class Vs Boundary Testing Let us discuss about the difference between Equivalence class and boundary testing. For the discussion we will use the practice question: Bank account can be integer in the following ranges: 500 to 1000 or 0 to 499 or 2000. What are the equivalence classes? Answer:
In equivalence class, you need to take one value from each class and test whether the value causes the system to act as the class' definition. It means that in this example, you need to create at least 6 test cases – one for each valid class and one for each invalid class. How many test cases will be, if you use boundary testing? The following table shows how much test cases will be using "Boundary Testing" method:
In boundary testing, you need to test each value in the boundary and you know the value, you don't need to choose it from any set. In this example you have 13 test cases. Now, let us exam how to combine this 2 methods together. The following table shows all the boundary testing values and their equivalence classes:
Now, we can reduce some of the test cases that belong to the same equivalence class. We can delete lines 3 and 4 which belong to equivalence class "0 <= account <= 499". We also can delete lines 7 and 8 hich belong to "500 <= account <= 1000". The new table will be:
You can even reduce more test cases although in my opinion, it is important to keep this table because it keeps a hard connection to the boundary testing. You can see in the table that I didn't reduce those test cases that are touch in the boundary itself of each range. Let's reduce more test cases (just for the fun and for the practice (test case 5, 9 and 10):
Now, in this table, for each equivalence class, you choose one value that belongs to boundary testing. A smart man once told me that when I write a test case and I using equivalence class partitioning, not to write specific values. Instead, he told me to write the classes and their expected results. By that, each time a tester will run the test case he will choose new candidates from each class. Using that working method we can promise that each running will contain new values. |

 
 




inar

good article ... comprehensive and accurate ... detailed and easy to understand .... must read ... thanks for sharing