Sunday 20 September 2015

Different Types of Test Case Design Techniques


Test case design methods commonly used are:


  • Equivalence Partitioning (EP)
  • Boundary value analysis (BVA)
  • Negative Testing

1. Equivalence Partitioning: Equivalence partitioning is a software testing related technique with the goal:

  •  To Reduce the Number of Test Cases to a Necessary Minimum.
  •  To Select the Right Test Cases to cover all Possible Scenarios.

The Equivalence Partitions are usually derived from the specification of the component. An input has certain ranges which are valid and other ranges which are invalid.
This may be best explained by the example of a function which takes a parameter "month". The valid range for the month is 1 to 12, representing January to December. This valid range is called a partition. In this example there are two further partitions of invalid ranges. The first invalid partition would be <= 0 and the second invalid partition would be >= 13
... -2 -1 0               1 ........................................12              13 14 15..... -----------------------------------Invalid partition 1 valid partition                                         Invalid partition 2

The Testing theory related to equivalence partitioning says that only one test case of each partition is needed to evaluate the behavior of the program for the related partition. In other words it is sufficient to select one test case out of each partition to check the behavior of the program. To use more or even all test cases of a partition will not find new faults in the program. The values within one partition are considered to be "equivalent". Thus the number of test cases can be reduced considerably.
An additional effect by applying this technique is that you also find the so called "dirty" test cases. An inexperienced tester may be tempted to use as test cases the input data 1 to 12 for the month and forget to select some out of the invalid partitions. This would lead to a huge number of unnecessary test cases.
Equivalence Partitioning is No Stand Alone method to determine Test Cases. It has to be supplemented by Boundary Value Analysis (BVA). Having determined the partitions of possible inputs the method of boundary value analysis has to be applied to select the most effective test cases out of these partitions.
Equivalence Partitioning: A Black Box test design technique in which test cases are designed to execute representatives from equivalence partitions. In principle, test cases are designed to cover each partition at least once.
Equivalence partitioning is a software testing technique to minimize number of permutation and combination of input data. In equivalence partitioning, data is selected in such a way that it gives as many different output as possible with the minimal set of data.
For example of EP: consider a very simple function for awarding grades to the students. This program follows this guideline to award grades
Marks 00 - 39 ------------ Grade D
Marks 40 - 59 ------------ Grade C
Marks 60 - 70 ------------ Grade B
Marks 71 - 100 ------------ Grade A

Based on the equivalence partitioning techniques, partitions for this program could be as follows
Marks between 0 to 39 - Valid Input
Marks between 40 to 59 - Valid Input
Marks between 60 to 70 - Valid Input
Marks between 71 to 100 - Valid Input
Marks less than 0 - Invalid Input
Marks more than 100 - Invalid Input
Non numeric input - Invalid Input
From the example above, it is clear that from infinite possible test cases (Any value between 0 to 100, Infinite values for >100 , < 0 and non numeric) data can be divided into seven distinct classes. Now even if you take only one data value from these partitions, your coverage will be good.
Most important part in equivalence partitioning is to identify equivalence classes. Identifying equivalence classes needs close examination of the possible input values. Also, you can not rely on any one technique to ensure your testing is complete. You still need to apply other techniques to find defects.

2. Boundary Value Analysis (BVA): Boundary Value Analysis is a Software Test Case Design Technique used to determine test cases covering off-by-one errors.
Testing experience has shown that the boundaries of input ranges to a software component are likely to contain defects.
Example: A function that takes an integer between 1 and 12, representing a month between January to December, might contain a check for this range:

void exampleFunction(int month) { if (month > 0 && month < 13)
....
A common programming error is to check an incorrect range e.g. starting the range at 0 by writing:
void exampleFunction(int month) { if (month >= 0 && month < 13)
....
For more complex range checks in a program this may be a problem which is not so easily spotted as in the above simple example.
Applying Boundary Value Analysis (BVA):
To set up boundary value analysis test cases, the tester first determines which boundaries are at the interface of a software component. This is done by applying the equivalence partitioning technique. For the above example, the month parameter would have the following partitions:
... -2 -1 0            1................................12 13 14 15.....
------------------------|------------------------------|-------------------------
Invalid partition 1           valid partition             Invalid partition 2
To apply boundary value analysis, a test case at each side of the boundary between two partitions is selected. In the above example this would be 0 and 1 for the lower boundary as well as 12 and 13 for the upper boundary. Each of these pairs consists of a "clean" and a "negative" test case. A "clean" test case should lead to a valid result. A "negative" test case should lead to specified error handling such as the limiting of values, the usage of a substitute value, or a warning.
Boundary value analysis can result in three test cases for each boundary; for example if n is a boundary, test cases could include n-1, n, and n+1.

3. Negative Testing:
“Non Recommended Test Data generates the Negative Test Cases.”
Example:

  •  Entering future date in ‘Employee birth date’ field.
  •  Entering alphabets in numeric field like salary.
  •  Entering number in name field.

No comments:

Post a Comment