Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder...
Transcript of Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder...
![Page 1: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/1.jpg)
Truth Table-Based Testing
Generating test cases when the test model is a
truth table
Reading: Binder Chapter 6
![Page 2: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/2.jpg)
Example truth tableVariant Number
Normal Pressure
Call For Heat
Damper Shut Manual Mode Ignition Enable
A B C D Z
0 0 0 0 0 0
1 0 0 0 1 0
2 0 0 1 0 0
3 0 0 1 1 0
4 0 1 0 0 0
5 0 1 0 1 0
6 0 1 1 0 0
7 0 1 1 1 0
8 1 0 0 0 0
9 1 0 0 1 1
10 1 0 1 0 0
11 1 0 1 1 1
12 1 1 0 0 1
13 1 1 0 1 1
14 1 1 1 0 0
15 1 1 1 1 1
![Page 3: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/3.jpg)
Deriving the Logic Function Review boolean algebra
AB = A and B A+B = A or B ~A = not A
A logic function maps n boolean input variables to a boolean output variable
A truth table is an enumeration of all possible input and output values
![Page 4: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/4.jpg)
Logic function The logic function for the example is
Z = AB~C + AD Several techniques to derive it
Karnaugh maps Cause-effect graphs
A compact logic function will produce more powerful test cases
![Page 5: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/5.jpg)
Truth table approaches All-Variants: Every variant is tested once. The number of tests is 2N, infeasible for large tables
All-True: All variants that produce a true outcome are tested Inappropriate if false actions are an important part of the behaviour
All-False: All variants that produce a false outcome are tested Inappropriate if true actions are important
![Page 6: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/6.jpg)
Each-Condition/All-conditions Assumption: For the logic functions X=PQR and Y=P+Q+R, the only relevant cases are:
P Q R X
0 1 1 0
1 0 1 0
1 1 0 0
1 1 1 1
P Q R Y
0 0 1 1
0 1 0 1
1 0 0 1
0 0 0 0
![Page 7: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/7.jpg)
Each-Condition/All-conditions For a logic function such as
Z = AB~C + ADwe apply the heuristic to every termTest cases for
AB~C
A B C D
0 1 0 X
1 0 0 X
1 1 1 X
1 1 0 X
Test cases for AD
A B C D
1 X X 0
0 X X 1
1 X X 1
![Page 8: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/8.jpg)
Each-Condition/All-conditions The number of tests increases linearly with the number of product terms
Values need to be assigned to the Don’t Care variables. Can be done randomly or by suspicion. Try different combinations for different test cases
![Page 9: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/9.jpg)
Binary Decision Diagrams Compact representation of a truth table
Can be used to create test suite A BDD can be generated from the truth table
Start by drawing the full decision tree
A left branch represents False (0) A right branch represents True (1)
![Page 10: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/10.jpg)
Decision tree for boiler example
![Page 11: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/11.jpg)
Reduction process Working from left to right, replace leaf nodes with equivalent constants or variables and prune the branches
This way we can prune the entire left branch of the tree since it only depends on the value of A
![Page 12: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/12.jpg)
First Reduction
![Page 13: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/13.jpg)
Second Reduction
![Page 14: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/14.jpg)
Final Binary Decision Diagram
![Page 15: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/15.jpg)
BDD determinant table A BDD determinant is a root-to-leaf-path in the BDD
The BDD determinant table has one row per path
Variant
A B C D Z
1 0 X X X 0
2 1 0 X D D
3 1 1 1 D D
4 1 1 0 X 1
![Page 16: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/16.jpg)
Test suite generation All combinations of sensitive variables, e.g. D, are createdVariant
A B C D Z
1 0 X X X 0
2 1 0 X 0 0
2 1 0 X 1 1
3 1 1 1 0 0
3 1 1 1 1 1
4 1 1 0 X 1
![Page 17: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/17.jpg)
Variable Negation Strategy Designed to reveal faults that hide in a
don’t care The test suite contains:
Unique true points: A variant per term t, so that t is True and all other terms are False
Near False Points: A variant for each literal in a term. The variant is obtained by negating the literal and is selected only if it makes Z=0
Each variant creates a test candidate set Unique true point candidate sets in
boiler example: {12} {9,11,15}
![Page 18: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/18.jpg)
Example truth tableVariant Number
Normal Pressure
Call For Heat
Damper Shut Manual Mode Ignition Enable
A B C D Z
0 0 0 0 0 0
1 0 0 0 1 0
2 0 0 1 0 0
3 0 0 1 1 0
4 0 1 0 0 0
5 0 1 0 1 0
6 0 1 1 0 0
7 0 1 1 1 0
8 1 0 0 0 0
9 1 0 0 1 1
10 1 0 1 0 0
11 1 0 1 1 1
12 1 1 0 0 1
13 1 1 0 1 1
14 1 1 1 0 0
15 1 1 1 1 1
![Page 19: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/19.jpg)
Negation variants
Candidate set
number
Termnegation
Variants containing this
negation
Variants containing
this negation where Z=0
2 ABC 14,15 14
3 A~B~C 8,9 8
4 ~AB~C 4,5 4,5
6 A~D 8,10,12,14
8,10,14
7 ~AD 1,3,5,7 1,3,5,7
![Page 20: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/20.jpg)
Selecting the test cases At least one variant from each candidate set
Can be done by inspection Random selection is also used Near False Points exercise combinations of don’t care values
6% of all possible tests are created
98% of simulated bugs can be found
![Page 21: Truth Table-Based Testing Generating test cases when the test model is a truth table Reading: Binder Chapter 6.](https://reader036.fdocuments.us/reader036/viewer/2022062516/56649e565503460f94b4e8bf/html5/thumbnails/21.jpg)
Test suite Candidate sets121484,59,11,158,10,141,3,5,7
Minimum Test suite5891214