Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence...
Transcript of Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence...
![Page 1: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/1.jpg)
Input Space Partitioning
CMPT 473Software Quality Assurance
Nick Sumner - Fall 2014With material from Patrick Lam, Jeff Offutt
![Page 2: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/2.jpg)
2
Recall
● Testing involves running software and comparing observed behavior against expected behavior– Select an input, look at the output
![Page 3: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/3.jpg)
3
Recall
● Testing involves running software and comparing observed behavior against expected behavior– Select an input, look at the output
● Problem: The input domain is infinite or pragmatically infinite.
for test in allPossibleInputs: run_program(test)
![Page 4: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/4.jpg)
4
Recall
● Testing involves running software and comparing observed behavior against expected behavior– Select an input, look at the output
● Problem: The input domain is infinite or pragmatically infinite.
● Testing is about selecting a finite subset of inputs that can help measure quality
![Page 5: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/5.jpg)
5
Input Space Partitioning
Take the direct approach:Focus on the input!
![Page 6: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/6.jpg)
6
Input Space Partitioning
● Input Space Partitioning– Divide (partition) the set of possible inputs into
equivalence classes
![Page 7: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/7.jpg)
7
Input Space Partitioning
● Input Space Partitioning– Divide (partition) the set of possible inputs into
equivalence classes
– Test one input from each class
![Page 8: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/8.jpg)
8
Input Space Partitioning
● Input Space Partitioning– Divide (partition) the set of possible inputs into
equivalence classes
– Test one input from each class
e.g. abs(x)
Input Domain: …, -3, -2, -1, 0, 1, 2, 3, ...
How many tests if done exhaustively?
![Page 9: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/9.jpg)
9
…, -3, -2, -1, 0, 1, 2, 3, ...
Input Space Partitioning
● Input Space Partitioning– Divide (partition) the set of possible inputs into
equivalence classes
– Test one input from each class
e.g. abs(x)
Input Domain:
Partitions:
…, -3, -2, -1, 0, 1, 2, 3, ...
What might reasonable partitions be?
![Page 10: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/10.jpg)
10
Input Space Partitioning
● Input Space Partitioning– Divide (partition) the set of possible inputs into
equivalence classes
– Test one input from each class
e.g. abs(x)
Input Domain:
Partitions:
…, -3, -2, -1, 0, 1, 2, 3, ...…, -3, -2, -1, 0, 1, 2, 3, ...
![Page 11: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/11.jpg)
11
Input Space Partitioning
● Input Space Partitioning– Divide (partition) the set of possible inputs into
equivalence classes
– Test one input from each class
e.g. abs(x)
Input Domain:
Partitions:
…, -3, -2, -1, 0, 1, 2, 3, ...…, -3, -2, -1, 0, 1, 2, 3, ...
How many tests for the partitions?
![Page 12: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/12.jpg)
12
Input Space Partitioning
● Input Space Partitioning– Divide (partition) the set of possible inputs into
equivalence classes
– Test one input from each class
e.g. abs(x)
Input Domain:
Partitions:
…, -3, -2, -1, 0, 1, 2, 3, ...…, -3, -2, -1, 0, 1, 2, 3, ...
Impressive! How do we do it?
![Page 13: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/13.jpg)
13
Input Space Partitioning
1) Identify the component
![Page 14: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/14.jpg)
14
Input Space Partitioning
1) Identify the component– Whole program– Module– Class– Function
![Page 15: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/15.jpg)
15
Input Space Partitioning
1) Identify the component– Whole program– Module– Class– Function
2) Identify the inputs
What might the inputs be?
![Page 16: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/16.jpg)
16
Input Space Partitioning
1) Identify the component– Whole program– Module– Class– Function
2) Identify the inputs– Function/method parameters– File contents– Global variables– Object state– User provided inputs
![Page 17: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/17.jpg)
17
Input Space Partitioning
3) Develop an Input Domain Model
![Page 18: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/18.jpg)
18
Input Space Partitioning
3) Develop an Input Domain Model
What does that even mean?
![Page 19: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/19.jpg)
19
Input Space Partitioning
3) Develop an Input Domain Model– A way of describing the possible inputs
– Partitioned by characteristics
![Page 20: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/20.jpg)
20
Partitioned Input Domain
● Partition the domain D on characteristics
A B
CD =
![Page 21: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/21.jpg)
21
Partitioned Input Domain
● Partition the domain D on characteristics
A B
CD =
What are characteristics?
![Page 22: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/22.jpg)
22
Partitioned Input Domain
● Partition the domain D on characteristics● Must satisfy 2 criteria:
– Disjoint: A ∩ B ∩ C = ∅– Cover: A B C = D∪ ∪
A B
CD =
![Page 23: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/23.jpg)
23
Partitioned Input Domain
● Partition the domain D on characteristics● Must satisfy 2 criteria:
– Disjoint: A ∩ B ∩ C = ∅– Cover: A B C = D∪ ∪
A B
CD =
What do these criteria intuitively provide?
![Page 24: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/24.jpg)
24
Using Partitions● Select one input from each block
● Each input in a block is assumed equally useful
![Page 25: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/25.jpg)
25
Using Partitions● Select one input from each block
● Each input in a block is assumed equally useful
● How?
– Identify characteristics of the possible inputs(from requirements, types, etc.)
![Page 26: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/26.jpg)
26
Using Partitions● Select one input from each block
● Each input in a block is assumed equally useful
● How?
– Identify characteristics of the possible inputs(from requirements, types, etc.)
– Partition into blocks based on each characteristic
![Page 27: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/27.jpg)
27
Using Partitions● Select one input from each block
● Each input in a block is assumed equally useful
● How?
– Identify characteristics of the possible inputs(from requirements, types, etc.)
– Partition into blocks based on each characteristic
– Create tests by selecting values for each block
![Page 28: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/28.jpg)
28
Using Partitions● Select one input from each block
● Each input in a block is assumed equally useful
● How?
– Identify characteristics of the possible inputs(from requirements, types, etc.)
– Partition into blocks based on each characteristic
– Create tests by selecting values for each block
How many tests might this imply?Might there be more? Fewer?
![Page 29: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/29.jpg)
29
Using Partitions● Select one input from each block
● Each input in a block is assumed equally useful
● How?
– Identify characteristics of the possible inputs(from requirements, types, etc.)
– Partition into blocks based on each characteristic
– Create tests by selecting values for each block
We're hiding some details in this last step.It's not quite right yet.
How many tests might this imply?Might there be more? Fewer?
![Page 30: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/30.jpg)
30
Using Partitions● Select one input from each block
● Each input in a block is assumed equally useful
● How?
– Identify characteristics of the possible inputs(from requirements, types, etc.)
– Partition into blocks based on each characteristic
– Create tests by selecting values for each block
● Characteristics:
– List s is sorted ascending– X is null– String length– ...
![Page 31: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/31.jpg)
31
Partitioning is Subtle
● Suppose we have:
Characteristic: “The subtype of parallelogram”
classifyParallelogram(p1)
![Page 32: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/32.jpg)
32
Partitioning is Subtle
● Suppose we have:
Characteristic: “The subtype of parallelogram”
– How can we partition based on this characteristic?
– What problems might arise?
classifyParallelogram(p1)
![Page 33: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/33.jpg)
33
Partitioning is Subtle
● Suppose we have:
Characteristic: “The subtype of parallelogram”
– How can we partition based on this characteristic?
– What problems might arise?
● In class exercise:Partitioning a triangle classifying program
classifyParallelogram(p1)
![Page 34: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/34.jpg)
34
Partitioning is Subtle
● Suppose we have:
Characteristic: “The subtype of parallelogram”
– How can we partition based on this characteristic?
– What problems might arise?
● In class exercise:Partitioning a triangle classifying program
● It is easy to create overlapping partitions.– Care and design required to avoid it.
classifyParallelogram(p1)
![Page 35: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/35.jpg)
35
Partitioning is Subtle
● Suppose we have:
Characteristic: “The subtype of parallelogram”
– How can we partition based on this characteristic?
– What problems might arise?
● In class exercise:Partitioning a triangle classifying program
● It is easy to create overlapping partitions.– Care and design required to avoid it.
classifyParallelogram(p1)
Why do disjoint partitions matter?
![Page 36: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/36.jpg)
36
Process (Reiterated)
3 step process (for now):
1)Find the component / function to test
methods, classes, programs, functions
![Page 37: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/37.jpg)
37
Process (Reiterated)
3 step process (for now):
1)Find the component / function to test
methods, classes, programs, functions
![Page 38: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/38.jpg)
38
Process (Reiterated)
3 step process (for now):
1)Find the component / function to test
methods, classes, programs, functions
2)Find all test parameters● Must identify everything
locals, globals, files, databases, schedules, servers, ...
![Page 39: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/39.jpg)
39
Process (Reiterated)
3 step process (for now):
1)Find the component / function to test
methods, classes, programs, functions
2)Find all test parameters● Must identify everything
locals, globals, files, databases, schedules, servers, ...
3)Model the input domain● Identify characteristics● Partition the input domain● Select values for each region
![Page 40: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/40.jpg)
40
Process (Reiterated)
3 step process (for now):
1)Find the component / function to test
methods, classes, programs, functions
2)Find all test parameters● Must identify everything
locals, globals, files, databases, schedules, servers, ...
3)Model the input domain● Identify characteristics● Partition the input domain● Select values for each region
Domain knowledge, tactics, and creativity apply here.
![Page 41: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/41.jpg)
41
Approaches to Input Modeling
We still haven't talked about how to model input!
![Page 42: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/42.jpg)
42
Approaches to Input Modeling
2 Main approaches:
![Page 43: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/43.jpg)
43
Approaches to Input Modeling
2 Main approaches:
1)Interface based– Guided directly by identified parameters & domains
![Page 44: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/44.jpg)
44
Approaches to Input Modeling
2 Main approaches:
1)Interface based– Guided directly by identified parameters & domains– Simple– Automatable
![Page 45: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/45.jpg)
45
Approaches to Input Modeling
2 Main approaches:
1)Interface based– Guided directly by identified parameters & domains– Simple– Automatable
● Functionality/Requirements based– Derived from expected input/output by spec.
![Page 46: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/46.jpg)
46
Approaches to Input Modeling
2 Main approaches:
1)Interface based– Guided directly by identified parameters & domains– Simple– Automatable
2)Functionality/Requirements based– Derived from expected input/output by spec.– Requires more design & more thought– May be better (smaller, goal oriented, …)
![Page 47: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/47.jpg)
47
Interface Based Modeling
● Consider parameters individually
![Page 48: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/48.jpg)
48
Interface Based Modeling
● Consider parameters individually– Examine their types/domains
– Ignore relationships & dependences
![Page 49: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/49.jpg)
49
Interface Based Modeling
● Consider parameters individually– Examine their types/domains
– Ignore relationships & dependences
How does this apply to our triangle classifier?
![Page 50: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/50.jpg)
50
Functionality Based Modeling
● Identify characteristics corresponding to behaviors/functionality in the requirements
![Page 51: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/51.jpg)
51
Functionality Based Modeling
● Identify characteristics corresponding to behaviors/functionality in the requirements– Includes knowledge from the problem domain
![Page 52: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/52.jpg)
52
Functionality Based Modeling
● Identify characteristics corresponding to behaviors/functionality in the requirements– Includes knowledge from the problem domain
– Accounts for relationships between parameters
![Page 53: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/53.jpg)
53
Functionality Based Modeling
● Identify characteristics corresponding to behaviors/functionality in the requirements– Includes knowledge from the problem domain
– Accounts for relationships between parameters
– Same parameter may appear in multiple characteristics
● Need to reason about constraints & conflicts!
![Page 54: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/54.jpg)
54
Functionality Based Modeling
● Identify characteristics corresponding to behaviors/functionality in the requirements– Includes knowledge from the problem domain
– Accounts for relationships between parameters
– Same parameter may appear in multiple characteristics
● Need to reason about constraints & conflicts!
How might this apply to our triangle classifier?
![Page 55: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/55.jpg)
55
Finding Typical Characteristics
What might typical characteristics be?
![Page 56: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/56.jpg)
56
Finding Typical Characteristics
What might typical characteristics be?● Preconditions● Postconditions● Relationships to special values● Relationships between variables
Invariants
![Page 57: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/57.jpg)
57
Finding Typical Values
How might you select values for a block?
![Page 58: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/58.jpg)
58
Finding Typical Values
How might you select values for a block?● Expected values (e.g. exampled from spec)● Invalid, valid, & special values● Boundary values
![Page 59: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/59.jpg)
59
Finding Typical Values
How might you select values for a block?● Expected values (e.g. exampled from spec)● Invalid, valid, & special values● Boundary values
Thought experiment:What do boundary values as a selection approach indicate?
![Page 60: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/60.jpg)
60
An Interface Based Example
● Consider our triangle classifier– Takes 3 integers for sides 1, 2, & 3
![Page 61: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/61.jpg)
61
An Interface Based Example
● Consider our triangle classifier– Takes 3 integers for sides 1, 2, & 3
Characteristic b1 b2 b3Side 1 <?> 0 Side 1 > 0 Side 1 = 0 Side 1 < 0
Side 2 <?> 0 Side 2 > 0 Side 2 = 0 Side 2 < 0
Side 3 <?>0 Side 3 > 0 Side 3 = 0 Side 3 < 0
![Page 62: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/62.jpg)
62
An Interface Based Example
● Consider our triangle classifier– Takes 3 integers for sides 1, 2, & 3
Characteristic b1 b2 b3Side 1 <?> 0 Side 1 > 0 Side 1 = 0 Side 1 < 0
Side 2 <?> 0 Side 2 > 0 Side 2 = 0 Side 2 < 0
Side 3 <?>0 Side 3 > 0 Side 3 = 0 Side 3 < 0
How many tests does this create?
![Page 63: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/63.jpg)
63
An Interface Based Example
● Consider our triangle classifier– Takes 3 integers for sides 1, 2, & 3
Characteristic b1 b2 b3Side 1 <?> 0 Side 1 > 0 Side 1 = 0 Side 1 < 0
Side 2 <?> 0 Side 2 > 0 Side 2 = 0 Side 2 < 0
Side 3 <?>0 Side 3 > 0 Side 3 = 0 Side 3 < 0
How many tests does this create?
What will this test well?What won't this test well?
![Page 64: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/64.jpg)
64
Refining the Example
● We can subdivide partitions to cover more behavior
Characteristic b1 b2 b3 b4Value of side 1 Side 1 > 1 Side 1 = 1 Side 1 = 0 Side 1 < 0
Value of side 2 Side 2 > 1 Side 2 = 1 Side 2 = 0 Side 2 < 0
Value of side 3 Side 3 > 1 Side 3 = 1 Side 3 = 0 Side 3 < 0
{Side n > 0} → {Side n = 1},{ Side n > 1}
![Page 65: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/65.jpg)
65
Refining the Example
● We can subdivide partitions to cover more behavior
Characteristic b1 b2 b3 b4Value of side 1 Side 1 > 1 Side 1 = 1 Side 1 = 0 Side 1 < 0
Value of side 2 Side 2 > 1 Side 2 = 1 Side 2 = 0 Side 2 < 0
Value of side 3 Side 3 > 1 Side 3 = 1 Side 3 = 0 Side 3 < 0
How many tests now?
![Page 66: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/66.jpg)
66
Refining the Example
● We can subdivide partitions to cover more behavior
Characteristic b1 b2 b3 b4Value of side 1 Side 1 > 1 Side 1 = 1 Side 1 = 0 Side 1 < 0
Value of side 2 Side 2 > 1 Side 2 = 1 Side 2 = 0 Side 2 < 0
Value of side 3 Side 3 > 1 Side 3 = 1 Side 3 = 0 Side 3 < 0
How many tests now?
Is it still disjoint? Complete?
![Page 67: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/67.jpg)
67
Refining the Example
● We can subdivide partitions to cover more behavior
Characteristic b1 b2 b3 b4Value of side 1 Side 1 > 1 Side 1 = 1 Side 1 = 0 Side 1 < 0
Value of side 2 Side 2 > 1 Side 2 = 1 Side 2 = 0 Side 2 < 0
Value of side 3 Side 3 > 1 Side 3 = 1 Side 3 = 0 Side 3 < 0
How many tests now?
Is it still disjoint? Complete?
What does it test well? Not well?
![Page 68: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/68.jpg)
68
A Functionality Based Example
● Consider our triangle classifier again– What might our characteristics & partitions be?
![Page 69: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/69.jpg)
69
A Functionality Based Example
● Consider our triangle classifier again– What might our characteristics & partitions be?
– Are there alternatives?
![Page 70: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/70.jpg)
70
A Functionality Based Example
● Consider our triangle classifier again– What might our characteristics & partitions be?
– Are there alternatives?
– Why might you use them?
![Page 71: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/71.jpg)
71
A Classic Example
● Start with a component / specification:
Command FIND
Syntax FIND <pattern> <file>
Function The FIND command is used to locate one or more instances of a given pattern in a text file. All lines in the file that contain the pattern are written to standard output. A line containing the pattern is written only once, regardless of the number of times the pattern occurs on it.
The pattern is any sequence of characters whose length does not exceed the maximum length of a line in the file. To include a blank in the pattern, the entire pattern must be enclosed in quotes ("). To include a quotation mark in the pattern, two quotes in a row ("") must be used.
![Page 72: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/72.jpg)
72
A Classic Example
● Step 1: Analyze the specification– What is the component?
– What are the parameters?
– What are the characteristics?
![Page 73: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/73.jpg)
73
A Classic Example
● Step 1: Analyze the specification– What is the component?
– What are the parameters?
– What are the characteristics?
Parameters: Pattern Input file (& its contents!)
![Page 74: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/74.jpg)
74
A Classic Example
● Step 1: Analyze the specification– What is the component?
– What are the parameters?
– What are the characteristics?
Parameters: Pattern Input file (& its contents!)
Characteristics: Pattern Input file Pattern Size Quoting Embedded Quotes File NameEnvironment / System Characteristics: # of pattern occurrences in file # of occurrences on a particular line:
![Page 75: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/75.jpg)
75
A Classic Example
● Step 2: Partition the Input Space– Guided by intelligence and intuition
– Combine interface and functionality based approaches as necessary
![Page 76: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/76.jpg)
76
A Classic Example
● Step 2: Partition the Input Space– Guided by intelligence and intuition
– Combine interface and functionality based approaches as necessary
Parameters: Pattern Size: Empty Single character Many characters Longer than any line in the file Quoting:...
![Page 77: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/77.jpg)
77
A Classic Example
● Familiar Idea:– Select one region per characteristic at a time
– Combine into test frames (test case plans)
– e.g. …
![Page 78: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/78.jpg)
78
A Classic Example
● Familiar Idea:– Select one block per characteristic at a time
– Combine into test frames (test case plans)
– e.g.
Pattern size : emptyQuoting : pattern is quotedEmbedded blanks : several embedded blanksEmbedded quotes : no embedded quotesFile name : good file nameNumber of occurrences of pattern in file : nonePattern occurrences on target line : one
![Page 79: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/79.jpg)
79
A Classic Example
● Familiar Idea:– Select one block per characteristic at a time
– Combine into test frames (test case plans)
– e.g.
Pattern size : emptyQuoting : pattern is quotedEmbedded blanks : several embedded blanksEmbedded quotes : no embedded quotesFile name : good file nameNumber of occurrences of pattern in file : nonePattern occurrences on target line : one
Problem?
![Page 80: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/80.jpg)
80
A Classic Example
● Familiar Idea:– Select one block per characteristic at a time
– Combine into test frames (test case plans)
– e.g.
Pattern size : emptyQuoting : pattern is quotedEmbedded blanks : several embedded blanksEmbedded quotes : no embedded quotesFile name : good file nameNumber of occurrences of pattern in file : nonePattern occurrences on target line : one
Problem?
![Page 81: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/81.jpg)
81
A Classic Example
● Step 3: Identify constraints among the characteristics & blocks
Pattern Size: Empty [Property Empty] Single character [Property NonEmpty] Many characters [Property NonEmpty] Longer than any line in the file [Property NonEmpty]
![Page 82: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/82.jpg)
82
A Classic Example
● Step 3: Identify constraints among the categories
Pattern Size: Empty [Property Empty] Single character [Property NonEmpty] Many characters [Property NonEmpty] Longer than any line in the file [Property NonEmpty]
Quoting: Pattern is quoted [Property Quoted] Pattern is not quoted [If NonEmpty] Pattern is improperly quoted [If NonEmpty]
![Page 83: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/83.jpg)
83
A Classic Example
● Step 3: Identify constraints among the categories
Pattern Size: Empty [Property Empty] Single character [Property NonEmpty] Many characters [Property NonEmpty] Longer than any line in the file [Property NonEmpty]
Quoting: Pattern is quoted [Property Quoted] Pattern is not quoted [If NonEmpty] Pattern is improperly quoted [If NonEmpty]
What should this do to the number of tests?To the quality of tests?
![Page 84: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/84.jpg)
84
A Classic Example
● Step 4– Create tests by selecting values that satisfy the
selected blocks for each frame
– Eliminate tests that cover redundant scenarios
![Page 85: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/85.jpg)
85
A Classic Example
● Step 4– Create tests by selecting values that satisfy the
selected blocks for each frame
– Eliminate tests that cover redundant scenarios
Why might scenarios be redundant?
![Page 86: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/86.jpg)
86
A Classic Example
● Step 5:– Take your generated test cases and automate them
![Page 87: Input Space Partitioning - Simon Fraser Universitywsumner/teaching/473/03-input...equivalence classes – Test one input from each class 8 Input Space Partitioning Input Space Partitioning](https://reader033.fdocuments.us/reader033/viewer/2022053001/5f05c8b97e708231d414b084/html5/thumbnails/87.jpg)
87
Your Assignment
● Posted tonight/tomorrow morning.● You will be applying the C-P method to a file
parsing function of an open source project.