Monday, August 4, 2014

Equivalence partitioning with Examples:


Equivalence partitioning:


 Equivalence partitioning (also called Equivalence Class Partitioning) is a software testing
technique that divides the input data of a software unit into partitions of equivalent data from which test cases can be derived.

A shorter definition is that in this method the input domain data is divided into different equivalence data classes. This method is typically used to reduce the total number of test cases to a finite set of testable test cases, still covering maximum requirements.
Another much concrete definition is that equivalence partitioning is the process of taking all possible test cases and placing them into classes and, while testing, one test value is picked from each class.

Lets take the below question as example and try to understand how to analyse the questions related to  Equivalence partitioning:

Question:

If you are testing for an input box accepting numbers from 1 to 1000 then there is no use in writing thousand test cases for all 1000 valid input numbers plus other test cases for invalid data.

Analysis:

Using equivalence partitioning method above test cases can be divided into three sets of input data called as classes. Each test case is a representative of respective class.
So in above example we can divide our test cases into three equivalence classes of some valid and invalid inputs.
Test cases for input box accepting numbers between 1 and 1000 using Equivalence Partitioning:
1) One input data class with all valid inputs. Pick a single value from range 1 to 1000 as a valid test case. If you select other values between 1 and 1000 then result is going to be same. So one test case for valid input data should be sufficient.
2) Input data class with all values below lower limit. I.e. any value below 1, as a invalid input data test case.
3) Input data with any value greater than 1000 to represent third invalid input class.
So using equivalence partitioning you have categorized all possible test cases into three classes. Test cases with other values from any class should give you the same result.
We have selected one representative from every input class to design our test cases. Test case values are selected in such a way that largest number of attributes of equivalence class can be exercised.
Equivalence partitioning uses fewest test cases to cover maximum requirements.
I hope you understood how to analyse  Equivalence partitioning

Now lets solve the below simple example:

Question
In an Examination a candidate has to score minimum of 24 marks in order to clear the exam. The maximum that he can score is 40 marks.  Identify the Valid Equivalence values if the student clears the exam.
a)    22,23,26
b)    21,39,40
c)    29,30,31
d)    0,15,22
Solution
The classes will be as follows:
Class I: values < 24   => invalid class
Class II: 24 to 40       => valid class
Class III: values > 40 => invalid class
We have to indentify Valid Equivalence values. Valid Equivalence values will be there in Valid Equivalence class. All the values should be in Class II. So answer is ‘C’

Answer below questions for your better understanding:
Question 1: 

One of the fields on a form contains a text box which accepts numeric values in the range of 18 to 25. Identify the invalid Equivalence class.
a)    17
b)    19
c)    24
d)    21

Question 2:

In an Examination a candidate has to score minimum of 24 marks in order to clear the exam. The maximum that he can score is 40 marks.  Identify the Valid Equivalence values if the student clears the exam.
a)    22,23,26
b)    21,39,40
c)    29,30,31
d)    0,15,22







No comments:

Post a Comment