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...
Truth Table-Based Testing
Generating test cases when the test model is a
truth table
Reading: Binder Chapter 6
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
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
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
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
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
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
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
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)
Decision tree for boiler example
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
First Reduction
Second Reduction
Final Binary Decision Diagram
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
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
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}
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
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
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
Test suite Candidate sets121484,59,11,158,10,141,3,5,7
Minimum Test suite5891214