Upload
gervais-martin
View
215
Download
2
Embed Size (px)
Citation preview
CS451 – Software Testing Technologies
Blackbox Testing
Equivalence Partitioning
Equivalence Partitioning
Input domain
Too manytest inputs.
Four test inputs, one selected from each sub-domain.
12
3
4
Input domain partitioned into four sub-domains.
How to partition?
• Inputs to a program provide clues to partitioning.
• Example 1:– Suppose that program P takes an integer X as input X.
– For X<0 the program is required to perform task T1 and for
X>=0 task T2.
– P to behave the same way for all X<0.
– P to perform the same way for all values of X>=0.
We therefore partition the input domain of P into two sub-domains.
Two sub-domains
One test case:X=-3
Another test case:X=15
All test inputs in the X<0 sub-domain are considered equivalent.The assumption is that if one test input in this sub-domain revealsan error in the program, so will the others.
This is true of the test inputs in the X>=0 sub-domain also.
X<0 X>=0Equivalence class
Equivalence class
Non-overlapping Partitions• The equivalence classes are non-overlapping. In other words the two sub-domains are disjoint.• When the sub-domains are disjoint, it is sufficient to pick one test input from each equivalence
class to test the program.• An equivalence class is considered covered when at least one test has been selected from it. • In partition testing our goal is to cover all equivalence classes.
Overlapping Partitions• Example 2: Suppose that program P takes three
integers X, Y and Z. It is known that: X<Y and Z>Y
X<Y
X>=Y
Z>Y Z<=Y
X<Y, Z>YX=3, Y=4, Z=7
X<Y, Z<=YX=2, Y=3, Z=1
X>=Y, Z>YX=15, Y=4, Z=7
X>=Y, Z<=YX=15, Y=4, Z=1
Overlapping Partition-Test Selection
• In this example, we could select 4 test cases as:
– X=4, Y=7, Z=1 satisfies X<Y
– X=4, Y=2, Z=1 satisfies X>=Y
– X=1, Y=7, Z=9 satisfies Z>Y
– X=1, Y=7, Z=2 satisfies Z<=Y
• Thus, we have one test case from each equivalence class.
Overlapping Partitions-Test Selection
• However, we may also select only 2 test inputs and satisfy all four equivalence classes:
– X=4, Y=7, Z=1 satisfies X<Y and Z<=Y
– X=4, Y=2, Z=3 satisfies X>=Y and Z>Y
• Thus, we have reduced the number of test cases from 4 to 2 while covering each equivalence class.
Partitioning using non-numeric data
• In the previous two examples the inputs were integers. One can derive equivalence classes for other types of data also.
• Example 3:– Suppose that program P takes one character X and one
string Y as inputs. P performs task T1 for all lower case characters and T2 for upper case characters. Also, it performs task T3 for the null string and T4 for all other strings.
Partitioning using non-numeric data
X: lc
X:UC
Y: null Y: not nullX: lc, Y: null
X: lc, Y: not null
X: UC, Y: null
X: UC, Y: not null
lc: Lower case characterUC: Upper case characternull: null string.
Non-numeric Data
• Once again we have overlapping partitions.
• We can select only 2 test inputs to cover all four equivalence classes. These are:– X: lower case, Y: null string– X: upper case, Y: not a null string
Guidelines for equivalence partitioning
• Input condition specifies a range: create one for the valid case and
two for the invalid cases.
– e.g. for a<=X<=b the classes are
• a<=X<=b (valid case)
• X<a and X>b (the invalid cases)