Test design techniques
-
Upload
manindra-simhadri -
Category
Technology
-
view
547 -
download
2
Transcript of Test design techniques
![Page 1: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/1.jpg)
Test Design Techniques
co-sponsered by smackstuff.com
![Page 2: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/2.jpg)
co-sponsered by smackstuff.com
In this presentation…..In this presentation…..
Black Box Techniques
Equivalence Partioning
Boundary Value Analysis
White Box Techniques
Basis Path Testing
Control Structure Testing
Program Technique Testing
Mutation Testing
![Page 3: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/3.jpg)
co-sponsered by smackstuff.com
Equivalence partitioning
•The input domain is usually too large for exhaustive testing.
•It is therefore partitioned into a finite number of sub-domains for the selection of test inputs.
•Each sub-domain is known as an equivalence class and serves as a source of at least one test input.
![Page 4: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/4.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
Equivalence partitioning
Input domain
12
3
4
Input domain partitioned into four sub-domains.
Too manytest inputs.
Four test inputs, one selected from each sub-domain.
![Page 5: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/5.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
How to partition?
• Inputs to a program provide clues to partitioning.
• Example 1:
– Suppose that program P takes an input X, X being an integer.
– For X<0 the program is required to perform task T1 and for X>=0 task T2.
![Page 6: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/6.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
How to partition?-continued
– The input domain is prohibitively large because X can assume a large number of values.
– However, we expect P to behave the same way for all X<0. – Similarly, we expect P to perform the same way for all values of
X>=0.
– We therefore partition the input domain of P into two sub-
domains.
![Page 7: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/7.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
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
![Page 8: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/8.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
Non-overlapping partitions
• In the previous example, the two 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.
![Page 9: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/9.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
Overlapping partitions
• Example 2:– Suppose that program P takes three integers X, Y and Z. It is
known that:• X<Y • Z>Y
![Page 10: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/10.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
Overlapping partitions
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
![Page 11: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/11.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
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.
![Page 12: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/12.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
Overlapping partition-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.
![Page 13: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/13.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
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.
![Page 14: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/14.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
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.
![Page 15: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/15.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
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
![Page 16: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/16.jpg)
co-sponsered by smackstuff.com
Functio
nal te
sting
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)
![Page 17: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/17.jpg)
Guidelines-continued
co-sp
onse
red b
y sm
ackstu
ff.co
m
• Input condition specifies a value: create one for the valid value and two for incorrect values (below and above the valid value). This may not be possible for certain data types, e.g. for Boolean.
• Input condition specifies a member of a set: create one for the valid
value and one for the invalid (not in the set) value.
Design Techniques.
![Page 18: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/18.jpg)
Sufficiency of partitions
co-sp
onse
red b
y sm
ackstu
ff.co
m
• In the previous examples we derived equivalence classes based on the conditions satisfied by the input data.
• Then we selected just enough tests to cover each partition.• Think of the advantages and disadvantages of this approach!
Design Techniques
![Page 19: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/19.jpg)
co-sp
onse
red b
y sm
ackstu
ff.co
m
Boundary value analysis (BVA)
• Another way to generate test cases is to look for boundary values.• Suppose a program takes an integer X as input.• In the absence of any information, we assume that X=0 is a
boundary. Inputs to the program might lie on the boundary or on either side of the boundary.
Design Techniques
![Page 20: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/20.jpg)
co-sp
onse
red b
y sm
ackstu
ff.co
m
BVA: continued
• This leads to 3 test inputs:
X=0, X=-20, and X=14.Note that the values -20 and 14 are on either side of the boundary and are
chosen arbitrarily.
• Notice that using BVA we get 3 equivalence classes. One of these three classes contains only one value (X=0), the other two are
large!
Design Techniques
![Page 21: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/21.jpg)
April 12, 2023
co-sp
onse
red b
y sm
ackstu
ff.co
m
BVA: continued
• Now suppose that a program takes two integers X and Y and that x1<=X<=x2 and y1<=Y<=y2.
x1 x2
y2
y1
1 2
34
5
6
7
8
10
911
1213
14
Design Techniques
![Page 22: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/22.jpg)
co-sp
onse
red b
y sm
ackstu
ff.co
m
BVA-continued
• In this case the four sides of the rectangle represent the boundary.
• The heuristic for test selection in this case is:
Select one test at each corner (1, 2, 3, 4).
Select one test just outside of each of the four sides of the boundary (5, 6, 7, 8)
Design Techniques
![Page 23: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/23.jpg)
co-sp
onse
red b
y sm
ackstu
ff.co
m
BVA-continued
• Select one test just inside of each of the four sides of the boundary (10, 11, 12, 13).
• Select one test case inside of the bounded region (9).
• Select one test case outside of the bounded region (14).
How many equivalence classes do we get?
Design Techniques
![Page 24: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/24.jpg)
co-sp
onse
red b
y sm
ackstu
ff.co
m
BVA -continued
In the previous examples we considered only numeric data.BVA can be done on any type of data.For example, suppose that a program takes a string S and an integer X as
inputs. The constraints on inputs are: length(S)<=100 and a<=X<=b
Can you derive the test cases using BVA?
Design Techniques
![Page 25: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/25.jpg)
co-sp
onse
red b
y sm
ackstu
ff.co
m
BVA applied to output variables
Just as we applied BVA to input data, we can apply it to output data.
Doing so gives us equivalence classes for the output domain.
We then try to find test inputs that will cover each output equivalence class.
Design Techniques
![Page 26: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/26.jpg)
co-sp
onse
red b
y sm
ackstu
ff.co
m
White Box Testing Techniques
It is also called as open box or clear box.
• Basis Path Testing
• Control Structure Testing
• Program Technique Testing
• Mutation Testing
Design Techniques
![Page 27: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/27.jpg)
co-sp
onse
red b
y sm
ackstu
ff.co
m
Basis Path Testing
• Checking for the program running or not from all the possible flows
• Generate flow graph
• Calculate Cyclomatic complexity
Example
Design Techniques
1 + 1 + 1+ 1 = 4
Program Flow Graph
Cyclomatic complexity
![Page 28: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/28.jpg)
• Using this technique programmers can estimate the execution of the program without any interruption.
• Step1: Prepare a program with respect to program logic
• Step2: Prepare Flow Graph of that program
• Step3: Calculate cyclomatic complexity
• Step4: Run that program more than one time to cover all the independent paths
co-sp
onse
red b
y sm
ackstu
ff.co
m
Basis Path Testing
Design Techniques
![Page 29: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/29.jpg)
co-sp
onse
red b
y sm
ackstu
ff.co
m
Control Structure Testing
During this testing programmers validate the input and output correctness
Step1: Prepare the program according to the design logic
Step2: Execute the program
Step3: Check the input given to the program in all possible ways
Step4: Check the output of the program
Design Techniques
![Page 30: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/30.jpg)
• Using this technique programmers are testing the performance of the program with different inputs
• Step1: Prepare the program with respective design logic
• Step2: Execute the program with different inputs
• Step3: Calculate the process time
• Step4: If program execution time is not acceptable change the structure of the program without disturbing the functionality
co-sp
onse
red b
y sm
ackstu
ff.co
m
Program Technique Testing
Design Techniques
![Page 31: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/31.jpg)
• Programmers are making changes in the program to estimate the completeness and correctness of the program
co-sp
onse
red b
y sm
ackstu
ff.co
m
Mutation Testing
Design Techniques
Program
Program
Program
Change
Passed
Change
Failed
![Page 32: Test design techniques](https://reader034.fdocuments.in/reader034/viewer/2022042607/5564e04cd8b42ad9498b547c/html5/thumbnails/32.jpg)
Smackstuff.comSmackstuff.com
co-sponsered by smackstuff.com