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

Monday, May 7, 2012

Boundary Value Analysis (BVA)

By pushing one to the limits, you can see a totally different behavior from that person. Stretching a system to extremes will bring out its funny behavior. Usually this is applicable to all fields on the user interface. Always remember, most of the problems to our body happens due to bad input, name it bad food, or bad water or bad air. Same way, a system if it accepts bad inputs, it is in potential danger zone.

Let us take a simple voltage stabilizer that we connect to TV or fridge. Usually they give the range 190-240 volts 50 to 60 hertz input, output will be constant at 220 volts. If this needs to be tested, we need to look at some good and bad extremes.

  1. Connect to 190 volts
  2. Connect to 240 volts
  3. Connect to 189 volts
  4. Connect to 241 volts
In the above, we arrived at 4 conditions - be at the lowest boundary, be at the highest boundary, go below the lowest boundary and go beyond the highest boundary. We just varied one parameter - voltage. 

But there is one more parameter we have - cycles in Hertz. For that, keep a valid voltage and push that cycles to extremes.
  1. Connect to 220 volts 50 Hz
  2. Connect to 220 volts 60 Hz
  3. Connect to 220 volts 49 Hz
  4. Connect to 220 volts 61 Hz
By doing this, we make the system to go thru positive boundaries and negative boundaries. Withing the positive boundaries, the system must work; the system must stop working when it is put under negative boundaries.

Better to apply one parameter and push that to extreme, when we deal with multiple parameters. Else if the system fails, we may not be able to isolate the reason of failure.

In software, imagine you see a field that takes the date of journey in a travel portal. How can we apply the BVA technique in that field? Ask these questions and take a call.

  1. Can I book a ticket for today?
  2. Can I book a ticket for yesterday?
  3. Can I book a ticket for a day 180 days from now? (usually travel sites may allow upto 6 months)
  4. Can I book a ticket for a day 181 days from now?

This list may go as per the restrictions given by that portal. Same way, let us take a US zip code field. How can I apply BVA on a zip code field? A zip code is usually 5 digits such as 95014 or 5 digits hyphen 4 digits such as 95014-2367.

A few home work questions for you to apply BVA.

  1. Write BVA tests for USA social security number
  2. Write BVA tests for the interest rate field in a banking simple interest calculation screen. (interest rate is a percentage value)
When you deal with boundaries, there are 2 kinds of boundaries. Size boundary and value boundary. Value boundaries are the ones we discussed before. Size boundary indicate the number of characters that I can type in a field. You could have seen that many websites registration pages restrict the passwords to be minimum 6 characters and maximum 10 characters. In such cases, we need to test for 5 character password, 6 character password, 10 character password and 11 character password. 

Now is the twist - if a field has both size and value boundaries defined, you end up doing at least 8 tests for that one field alone! Good luck.

For more details, please refer to Open Mentor portal.