Equivalence Class partitioning & Boundary value analysis

Equivalence partitioning and Boundary value analysis both the techniques help us to find test data effectively which will almost cover all the test scenarios and its all help us in selection of test cases.

As we all know testing for all possible condition is not possible, if someone try to test software for all the possible condition then it might take more than 2-3 year or even more than that.

Take a example, suppose there is an e-commerce site under test and you are the Tester and one of the requirement of e-commerce site is ”user should get 5% discount on purchasing goods worth rupee 5,000 to 10,000 and if user purchase more than 10,001 then it should get 7% discount”.

After understanding the requirements testers need to write test cases. It is possible to check the discount for each amount ?? think on it. Would you write the test cases as follow ??

Under following condition user should not get any discount
--> check the discount when user purchase a goods of 1 rupee.
--> check the discount when user purchase a goods of 2 rupee.
.
.
.up to 
--> check the discount when user purchase a goods of 4999 rupee.


Under following condition user should get 5% discount
--> check the discount when user purchase a goods of 5001 rupee.
--> check the discount when user purchase a goods of 5002 rupee.
.
.up to 9999
--> check the discount when user purchase a goods of 10,000 rupee.

Under following condition user should get 7% discount
--> check the discount when user purchase a goods of 10,001 rupee.
--> check the discount when user purchase a goods of 10,002 rupee.
.
.up to infinity
--> check the discount when user purchase a goods of infinity rupee.

Now think on it, to just check the no discount condition means when user purchase a goods less than 5000 rupee then system should not give discount to her. To evaluate this for each and every condition tester need to write 5000 test cases. For the second condition means when user purchase a goods in between 5001 to 10,000 rupees, this requires 4999 test cases. And now last condition when user purchase a goods worth rupee more than 10,000 then there are infinite test cases need to be written.So this is possible to write such a huge number of test cases and execute them ??? Definitely a Big NO.

To overcome this problem. These techniques are developed. boundary value analysis and equivalence class partitioning are help us a lot. Using those techniques number of test cases can be reduced to few test cases without compromising the quality of testing. It can be useful in any testing phase, like it is useful in unit, integration , system etc. Means not restriction to use at particular phase.Both the testing techniques are Black Box Testing Techniques and Without knowing the code structure we can use these testing techniques. Let discuss first, Equivalence class partitioning. How does it help us for selection test cases.

Equivalence Class Partitioning :
Equivalence class partitioning, here we create a equivalence part means in simple word we create a equivalence partitions(groups). To understand this lets take a above given example and how do we make a part or group of it. 
Equivalence Class Partitioning
First understand the image. We have created three equivalence partitions,

First part is 0 to 4,999, second part is 4,999 to 10,000 and the third part and last one is from 10,000 to infinity.

Here we made an equivalence partition as per the condition given. Means logically if we purchase a good between 0 to 4,999 system should not give us any discount and in between 5,000 to 10,000 system should give us 5 % discount and above that we would get 7 % discount. Based on this scenario we made a equivalence part/group As you can see in above image.

So using this techniques we will select one value from each partition / part. So from first group we have selected value 2,999, from second group we have selected value 6,500 and from last group we have selected an values 11,200 and 22,888.

So after using Equivalence class partitioning, we have derived following test cases.

--> check the discount when user purchase a goods of 2,999.
Expected Result : user should not get any discount.

--> check the discount when user purchase a goods of 6,500.
Expected Result : user should get 5% discount.

--> check the discount when user purchase a goods of 11,200.
Expected Result : user should get 7% discount.

--> check the discount when user purchase a goods of 22,888.
Expected Result : user should get 7% discount.

See just a 4 test cases by using equivalence class partitioning. Test case numbers are dramatically decreased to just 4 and we will derive few more test cases from boundary value analysis which we will be discussed below.

Boundary Value Analysis :
Boundary Value analysis, if you carefully read it, you will get some idea about how boundary value analysis work. Here we also need to create a partition as we created in equivalence class partitioning but unlike selecting any value from each partition, here in boundary value analysis we select a value which is one less than partition and one more than partition and equal to partition.

Boundary Value Analysis

See the image, partition values are 0, 4999 and 10000 these are the partitions. So in boundary value analysis we need to select the value -1,0 and +1 for 0 partition and 4998, 4999, 5000 for partition 4,999 and for the last partition we will get 9999,10000 and 10001.

Means we will have 9 test cases with test data from boundary value analysis as shown below.

--> check the discount when user purchase a goods of -1 rupee.
Expected Result : System should not allow purchase of -1 rupee goods. (this looks like unrealistic test case but it is possible, suppose if you added a goods say watch and in price you entered -1 if system does not have validation then it will accept -1 also.)

--> check the discount when user purchase a goods of 0 rupee.
Expected Result : System should prevent 0 rupees goods.

--> check the discount when user purchase a goods of +1 rupee.
Expected Result : user should not get any discount.

--> check the discount when user purchase a goods of 4,998 rupee.
Expected Result : user should not get any discount.

--> check the discount when user purchase a goods of 4,999 rupee.
Expected Result : user should not get any discount.

--> check the discount when user purchase a goods of 5,000 rupee.
Expected Result : user should get 5% discount.

--> check the discount when user purchase a goods of 9,999 rupee.
Expected Result : user should get 5% discount.

--> check the discount when user purchase a goods of 10,000 rupee.
Expected Result : user should get 7% discount.

--> check the discount when user purchase a goods of 10,001 rupee.
Expected Result : user should get 7% discount.

See whole requirement will get tested within just 13 test cases. By using boundary value analysis and equivalence class partitioning we can derive data and also reduce the test cases require to evaluate whole system.

In short word we can say :
Equivalence Class Partitioning : means selecting any value from each partition.
Boundary Value Analysis : select the value which is one less than partition, one more than partition and one equal to partition.

No comments:

Post a Comment