Monday, May 28, 2012

Equivalence Partitions

When we deal with a lot of data, it seems to be ever increasing to test and exhaust. Let us take a simple courier management application. Typical inputs are - from address, to address, weight of the packet to be couriered, any insurance to be used for the parcel. Based on these, the price is calculated by the system. Imagine you are the tester for this application, what kind of test conditions you will write?

Let us divide the problem into different segments. See the conditions below.
  1. Sending a packet from your home to another house in the same street
  2. Sending a packet from your home to another house in same zip code or area code
  3. Sending a packet from your home to another house in another city, but within the same state
  4. Sending a packet from your home to another house in another city, but outside the state
  5. Sending a packet from your home to another house in another city, but outside the country
Do you see a pattern? We try to get a sample of each business scenario that can happen in real time. One sample is a representative of a lot of similar data. The trick is to identify as many number of good samples, as possible. Another set of samples would be based on the weight of the packet. Usually the charges would be x1 for 10-100 grams,  x2 for 101-250 grams, x3 for 251-500 grams, x4 for 501-1000 grams and so on. If we need to get samples for these different slabs of the packets, what values should I choose? Should I take 4 packets with weights 10, 101, 251, 501 grams each or 100, 250, 500, 1000 grams each? There is no hard an fast rule here - but the boundary values will always be taken care in your BVA test conditions. When it comes to Equivalence Partition, it is advised to take the middle values when it comes to numbers. So if I need to give 4 samples based on weight of the packet, I would choose 50, 175, 375, 750 grams each. These 4 samples clearly represent the 4 slabs of the packet weights.

Let us take a bank that takes deposits. There are many parameters that determine the interests on deposits - but let me take 2 key parameters - Interest Type - Compound or Simple,  and the other one is Deposit Period Tag - Daily, Monthly, Yearly. If we alter these 2 parameters, the interest varies. Look at the following options:
  1. Simple interest, applied on Daily basis
  2. Simple interest, applied on Monthly basis
  3. Simple interest, applied on Yearly basis
  4. Compound interest, applied on Daily basis
  5. Compound interest, applied on Monthly basis
  6. Compound interest, applied on Yearly basis
If we carefully look at the above samples, 2 parameters with 2 and 3 different values, resulted in 6 combination samples. Thus, when the number of parameters and values of the parameters keep increasing, the number of samples you have to choose will also keep increasing.


Exercise: Take a travel booking site. From city, to city, round trip/one way, adults/children count, accommodation required etc. will appear on the screen as input parameters. Arrive at the combinations of these as test samples based on equivalence partition technique.


For recorded sessions on software testing, visit us at www.openmentor.net.



No comments:

Post a Comment