08 Requirements Based Predicate Testing One Slide
08 Requirements Based Predicate Testing One Slide
for
Predicate Testing
W. Eric Wong
Department of Computer Science
The University of Texas at Dallas
[email protected]
http://www.utdallas.edu/~ewong
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 1
Speaker Biographical Sketch
Professor & Director of International Outreach
Department of Computer Science
University of Texas at Dallas
Guest Researcher
Computer Security Division
National Institute of Standards and Technology (NIST)
Vice President, IEEE Reliability Society
Secretary, ACM SIGAPP (Special Interest Group on Applied Computing)
Principal Investigator, NSF TUES (Transforming Undergraduate Education in
Science, Technology, Engineering and Mathematics) Project
– Incorporating Software Testing into Multiple Computer Science and Software
Engineering Undergraduate Courses
Founder & Steering Committee co-Chair for the SERE conference
(IEEE International Conference on Software Security and Reliability)
(http://paris.utdallas.edu/sere13)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 2
Learning Objectives
Equivalence Class partitioning Essential black-box techniques
for generating tests for
Boundary value analysis functional testing
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 3
Three Techniques
BOR
BRO
BRE
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 4
Test Generation from Predicates (1)
We will now examine three techniques
– BOR (Boolean Operator)
– BRO (Boolean and Relational Operator), and
– BRE (Boolean Relational Expression)
for generating test cases that are guaranteed to detect certain faults in the
coding of conditions
The conditions from which test cases are generated might arise from
requirements or might be embedded in the program to be tested.
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 5
Test Generation from Predicates (2)
A condition is represented formally as a predicate, also known as a
Boolean expression. For example, consider the requirement
“if the printer is ON and has paper then send document to printer”
This statement consists of a condition part and an action part.
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 6
Predicates
Relational operators (relop): {<, ≤, >, ≥, =, ≠}
= and = = are equivalent
Boolean operators (bop): {!, ∧, ∨, xor} also known as
{not, AND, OR, XOR}
Relational expression: e1 relop e2 (e.g., a + b < c)
e1 and e2 are expressions whose values
can be compared using relop
Simple predicate: A boolean variable or a relational expression
(e.g., x < 0)
Compound predicate: Join one or more simple predicates using bop
(e.g., gender = = “female” ∧ age > 65)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 7
Boolean Expressions (1)
Boolean expression: one or more Boolean variables joined by bop.
– Example: (a ∧ b ∨ !c) where a, b, and c are also known as literals.
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 8
Boolean Expressions (2)
Disjunctive normal form (DNF): Sum of product terms:
e.g., (pq) + (rs) + (ac).
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 9
Boolean Expressions (3)
Mutually singular: Boolean expressions e1 and e2 are mutually singular
when they do not share any literal
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 10
Boolean Expressions: Syntax Tree Representation
Abstract syntax tree (AST) for (a + b) < c ∧ !p
Internal nodes are labeled by boolean and relational operators
<
!
(a + b) c p
Leaf nodes
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 11
Fault Model for Predicate Testing
What kind of faults are we targeting when testing for the correct
implementation of predicates?
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 12
Boolean Operator Faults
Correct predicate: (a < b) ∨ (c > d) ∧ e
(a < b) ∧ (c > d) ∧ e Incorrect Boolean operator
(a < b) ∨ !(c > d) ∧ e Incorrect negation operator
(a < b) ∧ (c > d) ∨ e Incorrect Boolean operators
(a < b) ∨ (c > d) ∧ x Incorrect Boolean variable
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 13
Relational Operator Faults
Correct predicate: (a < b) ∨ (c > d) ∧ e
(a = = b) ∨ (c > d) ∧ e Incorrect relational operator
(a = = b) ∨ (c ≤ d) ∧ e Two relational operator faults
(a = = b) ∨ (c > d) ∨ e Incorrect relational and Boolean operators
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 14
Missing or Extra Boolean Variable Faults
Correct predicate: a ∨ b
Missing Boolean variable fault: a
Extra Boolean variable fault: a ∨ b ∧ c
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 15
Goal of Predicate Testing (1)
Given a correct predicate pc, the goal of predicate testing is to generate a
test set T such that there is at least one test case t ∈ T for which pc and its
faulty version pi evaluate to different truth values (i.e., pc = true and
pi = false or vice versa)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 16
Goal of Predicate Testing (2)
As an example, suppose that pc: a < b + c and pi: a > b + c
Consider a test set T = {t1, t2} where
t1: <a = 0, b = 0, c = 0> and t2: <a = 0, b = 1, c = 1>
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 17
Predicate Constraints: BR symbols
Consider the following Boolean-Relational set of BR-symbols:
– BR={t, f, <, =, >}
For example, consider the predicate E: a < b and the constraint “ > ”.
– A test case that satisfies this constraint for E must cause E to evaluate to false.
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 18
Infeasible Constraints
A constraint C is considered infeasible for predicate pr if there exists no
input values for the variables in pr that satisfy C.
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 19
Predicate Constraints
Let pr denote a predicate with n, n > 0, ∨ and ∧ operators
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 20
Predicate Constraints: Example
Consider the predicate pr: b ∧ (r < s) ∨ (u ≥ v) and a constraint C: (t, =, >)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 21
True and False Constraints
pr(C) denotes the value of predicate pr evaluated using a test case that
satisfies C
S = St ∪ Sf
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 22
Predicate Testing: Criteria
Given a predicate pr, we want to generate a test set T such that
– T is minimal and
– T guarantees the detection of the faults (correspond to some fault model)
in the implementation of pr
We will discuss three such criteria named
– BOR (Boolean Operator),
– BRO (Boolean and Relational Operator), and
– BRE (Boolean Relational Expression)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 23
Predicate Testing: BOR Testing Criterion
A test set T that satisfies the BOR testing criterion for a compound
predicate pr guarantees the detection of single or multiple Boolean
operator faults in the implementation of pr
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 24
Predicate Testing: BRO Testing Criterion
A test set T that satisfies the BRO testing criterion for a compound
predicate pr guarantees the detection of single Boolean operator and
relational operator faults in the implementation of pr
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 25
Predicate Testing: BRE Testing Criterion
A test set T that satisfies the BRE testing criterion for a compound
predicate pr guarantees the detection of single Boolean operator,
relational expression, and arithmetic expression faults in the
implementation of pr
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 26
Predicate Testing: Guaranteeing Fault Detection
Let Tx, x ∈ {BOR, BRO, BRE}, be a test set derived from predicate pr
Let pf be another predicate obtained from pr by injecting single
(or multiple) faults of one of three kinds
– Boolean operator fault
– relational operator fault, and
– arithmetic expression fault
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 27
Guaranteeing Fault Detection: Example
Let pr = a < b ∧ c > d
Constraint set S = {(t, t), (t, f ), (f, t)} Given to you at this moment
Let TBOR = {t1, t2, t3} is a BOR adequate test set that satisfies S
t1: < a = 1, b = 2, c = 1, d = 0 > satisfies (t, t)
(i.e., a < b is true and c < d is also true)
t2: < a = 1, b = 2, c = 1, d = 2 > satisfies (t, f)
t3: < a = 1, b = 0, c = 1, d = 0 > satisfies (f, t)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 28
Guaranteeing Fault Detection: In Class Exercise (1)
Inject single or multiple Boolean operator faults in
pr: a < b ∧ c > d
and show that T guarantees the detection of each fault.
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 29
Guaranteeing Fault Detection: In Class Exercise (2)
The following table lists pr and a total of 7 faulty predicates obtained by
inserting single and multiple Boolean operator faults in pr
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 30
Guaranteeing Fault Detection: In Class Exercise (3)
Can we delete any of these three test cases in T and still guarantee
the detection of all the Boolean operator faults?
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 31
Guaranteeing Fault Detection: In Class Exercise (4)
Suppose we remove t2, then the faulty predicate 4 in the previous
table cannot be distinguished from pr by tests t1 and t3 BRO
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 32
Cross & Onto Product
The cross product of two sets A and B is defined as
A × B = {(a, b) | a ∈ A and b ∈ B}
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 33
Set Products: Example (1)
Let A = {t, =, >} and B = {f, <}
A × B = {(t, f ), (t, <), (=, f), (=, <), (>, f), (>, <)}
A ⊗ B = {(t, f ), (=, <), (>, <)}
Any other possibilities for A ⊗ B?
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 34
Set Products: Example (2)
Let A = {t, =, >} and B = {f, <}
Any other possibilities for A ⊗ B?
A ⊗ B = {(t, <), (=, f ), (>, <)} second possibility
A ⊗ B = {(t, f ), (=, <), (>, f )} third possibility
A ⊗ B = {(t, <), (=, <), (>, f )} fourth possibility
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 35
Algorithm for Generation of BOR Constraint Sets (1)
We will use the following notation:
pr is a predicate
AST (pr) is its abstract syntax tree
N1, N2, …. refer to various nodes in the AST (pr)
SN is the constraint set for node N in the syntax tree for pr
SNt is the true constraint set for node N in the syntax tree for pr
SNf is the false constraint set for node N in the syntax tree for pr
SN = SNt ∪ SNf
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 36
Algorithm for Generation of BOR Constraint Sets (2)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 37
Algorithm for Generation of BOR Constraint Sets (3)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 38
Generation of BOR Constraint Set (1)
We want to generate TBOR for pr: a < b ∧ c > d
a<b c>d
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 39
Generation of the BOR Constraint Set (2)
Second, label each leaf node with the constraint set {(t), (f)}
We label the nodes as N1, N2, and so on for convenience.
N3
∧
N1 N2
a<b c>d
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 40
Generation of the BOR Constraint Set (3)
Third, compute the constraint set for the next higher node in the syntax
tree, in this case N3
For an AND node, the formulae used are the following.
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 41
Generation of TBOR
As per our objective, we have computed the BOR constraint set for the
root node of the AST(pr). We can now generate a test set using the BOR
constraint set associated with the root node.
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 42
Another Example for TBOR (1)
Generate the BOR-constraint sets for the predicate
(a + b) < c ∧ !p ∨ (r > s)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 43
Another Example for TBOR (2)
The abstract syntax tree for (a + b) < c ∧ !p ∨ (r > s)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 44
Generation of BRO Constraint Set
Recall that a test set adequate with respect to a BRO constraint set for
predicate pr guarantees the detection of all combinations of single
Boolean operator and relational operator faults.
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 45
BRO Constraint Set
The BRO constraint set S for relational expression e1 relop e2
S = {(>), (=), (<)}
The separation of S into its true (S t) and false (S f) components depends in
relop
relop: > S t = {(>)} Sf = {(=), (<)}
relop: ≥ S t = {(>), (=)} Sf = {(<)}
relop: = S t = {(=)} Sf = {(<), (>)}
relop: < S t = {(<)} Sf = {(=), (>)}
relop: ≤ S t = {(<), (=)} Sf = {(>)}
Note: tN denotes an element of S t N
fN denotes an element of S f N
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 46
Algorithm for Generation of BRO Constraint Sets
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 47
BRO Constraint Set: Example (1)
pr: (a + b < c) ∧ !p ∨ (r > s)
Step 1: Construct the AST for the given predicate
N6
N4
∧ N5
r>s
N1
N3
a+b<c !
p N2
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 48
BRO Constraint Set: Example (2)
Step 2: Label each leaf node with its constraint set S
N6
N4
∧ r>s
N5
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 49
BRO Constraint Set: Example (3)
Step 2: Traverse the tree and compute constraint set for each internal
node
S tN3 = SN2f = {(f)}
S fN3 = SN2t = {(t)}
S tN4 = SN1t ⊗ SN3t = {(<)} ⊗ {(f)} = {(<, f)}
S fN4 = (S fN1 × {(tN3)}) ∪ ({(tN1)} × S fN3)
= ({(>, =)} × {(f)}) ∪ ({(<)} × {(t)})
= {(>, f), (=, f)} ∪ {(<, t)}
= {(>, f), (=, f), (<, t)}
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 50
BRO Constraint Set: Example (4)
N4
∧ True constraint {f}
r>s 5
N
False constraint {t} True constraint {>}
N1 N3
a+b<c ! False constraint {<, =}
True constraint {<}
False constraint {>, =} p N2
True constraint {t}
False constraint {f}
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 51
BRO Constraint Set: Example (5)
Next compute the constraint set for the root node (this is an OR-node)
S fN6 = S fN4 ⊗ S fN5
= {(>, f), (=, f), (<, t)} ⊗ {(=), (<)}
= {(>, f, =), (=, f, <), (<, t, =)}
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 52
BRO Constraint Set: Example (6)
Constraint set for pr: (a + b < c) ∧ !p ∨ (r > s)
True constraint {(<, f, =), (>, f, >)}
False constraint {(>, f, =), (=, f, <), (<, t, =)} N6
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 53
BRO Constraint Set: In-
In-Class Exercise
Given the constraint set for pr: (a + b < c) ∧ !p ∨ (r > s), construct TBRO
{(>, f, =), (=, f, <), (<, t, =), (<, f, =), (>, f, >)}
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 54
Generating the BRE Constraint Set (1)
We now show how to generate BRE constraints that lead to test cases
which guarantee the detection of a single occurrence of
Boolean operator, relation operator, arithmetic expression, or
combination fault in a predicate
The BRE constraint set for a Boolean variable remains {t, f} as with the
BOR and BRO constraint sets
The BRE constraint set for a relational expression is {(+ε), (=), (−ε)}
where ε > 0
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 55
Generating the BRE Constraint Set (2)
The BRE constraint set S for a relational expression e1 relop e2 is
separated into subsets S t and S f based on the following relations
Based on the conditions listed above, we can now separate the BRE
constraint S into its true and false components as follows
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 56
Algorithm for Generation of BRE Constraint Sets (1)
The procedure to generate a minimal BRE-constraint set is similar to that
for BRO and BOR. The only difference lies in the construction of the
constraint sets for the leaves.
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 57
Algorithm for Generation of BRE Constraint Sets (2)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 58
BRE Constraint Set: Example (1)
Generate the constraint set for the predicate pr: (a + b < c) ∧ !p ∨ (r > s)
N6
∨
N4
∧ N5
r>s
N1
N3
a+b<c !
N2
p
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 59
BRE Constraint Set: Example (2)
BRE constraint set
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 60
BRE Constraint Set: Example (3)
A sample test set (TBRE) that satisfies the BRE constraints (ε = 1)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 61
Singular Boolean Expressions
Boolean expression: one or more Boolean variables joined by bop
– Example (a ∧ b ∨ !c), where a, b, and c are also known as literals
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 62
Mutually Singular Boolean Expressions
Mutually singular: Boolean expressions e1 and e2 are mutually singular
when they do not share any literal
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 63
BOR Constraints for Non-
Non-Singular Expressions
Test generation procedures described so far are for singular predicates.
Recall that a singular predicate contains only one occurrence of each
variable
We will now learn how to generate BOR constraints for non-singular
predicates
First, let us look at some non-singular expressions, their respective
disjunctive normal forms (DNF), and their mutually singular components
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 64
Non-
Non-Singular Expressions and DNF: Examples
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 65
Generating BOR Constraints for Non-
Non-Singular Expressions
We proceed in two steps
– First we will examine the Meaning Impact (MI) procedure for generating a
minimal set of constraints from a possibly non-singular predicate
– Next, we will examine the procedure to generate BOR constraint set for a
non-singular predicate
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 66
Meaning Impact (MI) Procedure (1)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 67
Meaning Impact (MI) Procedure (2)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 68
MI Procedure: Example (1)
Consider the non-singular predicate: a(bc + !bd)
Its DNF equivalent is E = abc + a!bd
Note that a, b, c, and d are Boolean variables and also referred to as
literals
– Each literal represents a condition
– For example, a could represent r < s
Recall that + is the Boolean OR operator, ! is the Boolean NOT operator,
and as per common convention we have omitted the Boolean AND
operator. For example bc is the same as b ∧ c
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 69
MI Procedure: Example (2)
Step 0: Identify the DNF equivalent of E as e1 + e2, where e1 = abc and
e2 = a!bd
– Note that the four t’s in the first element of Te denote the values of the
1
Boolean variables a, b, c, and d, respectively. The second element, and others,
are to be interpreted similarly.
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 70
MI Procedure: Example (3)
Step 2: From each Tei , remove the constraints that are in any other Tej
This gives us TSei and TSej
Note that this step will lead TSei ∩ TSej = ∅
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 71
MI Procedure: Example (4)
Step 3: Construct S tE by selecting one element from each TS
– In our case, selecting one test each from TSe and TSe , we obtain a minimal set
1 2
– Note that
There exist four possible S tE
For each constraint x in S tE we get E(x) = true
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 72
MI Procedure: Example (5)
Step 4: For each term in E, obtain terms by complementing each literal,
one at a time
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 73
MI Procedure: Example (6)
Fe11 = {(f, t, t, t), (f, t, t, f )}
Fe21 = {(t, f, t, t), (t, f, t, f )}
Fe31 = {(t, t, f, t), (t, t, f, f )}
Fe12 = {(f, f, t, t), (f, f, f, t)}
Fe22 = {(t, t, t, t), (t, t, f, t)}
Fe32 = {(t, f, t, f ), (t, f, f, f )}
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 74
MI Procedure: Example (7)
Step 5: Now construct FSe by removing from Fe any constraint that
appeared in any of the sets Te constructed earlier.
FSe11 = Fe11
FSe21 = {(t, f, t, f )}
FSe31 = Fe31
Constraints common with
Te1 and Te2 are removed.
FSe12 = Fe12
FSe22 = {(t, t, f, t)}
FSe32 = Fe32
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 75
MI Procedure: Example (8)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 76
BOR-
BOR-MI-
MI-CSET Procedure (1)
The BOR-MI-CSET procedure takes a possibly non-singular expression
E as input and generates a constraint set that guarantees the detection of
Boolean operator faults in the implementation of E
The BOR-MI-CSET procedure using the MI procedure described earlier
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 77
BOR-
BOR-MI-
MI-CSET Procedure (2)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 78
BOR-
BOR-MI-
MI-CSET: Example (1)
Consider a non-singular Boolean expression: E = a(bc + !bd)
Mutually singular components of E
e1 = a singular
e2 = bc + !bd non-singular
We use the BOR-CSET procedure to generate the constraint set for e1
(singular component) and MI-CSET procedure for e2 (non-singular
component)
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 79
BOR-
BOR-MI-
MI-CSET: Example (2)
For component e1 we get
S t e1 = {t}. S fe1 = {f}
Recall that S te1 is true constraint set for e1 and S fe1 is false constraint set
for e1
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 80
BOR-
BOR-MI-
MI-CSET: Example (3)
Component e2 is a DNF expression. We can write e2 = u + v where u = bc
and v = !bd
Let us now apply the MI-CSET procedure to obtain the BOR constraint
set for e2
As per Step 1 of the MI-CSET procedure we obtain
Tu = {(t, t, t), (t, t, f )}
Tv = {(f, t, t), (f, f, t)}
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 81
BOR-
BOR-MI-
MI-CSET: Example (4)
Applying Steps 2 and 3 to Tu and Tv we obtain
TSu = Tu = {(t, t, t), (t, t, f)} One possible choice. Can you
TSv = Tv = {(f, t, t), (f, f, t)} think of other alternatives?
Ste2 = {(t, t, f), (f, t, t)}
Next we apply Step 4 to u and v. We obtain the following complemented
expressions from u and v.
Note that u = bc and v = !bd
u1 = !bc u2 = b!c
v1 = bd v2 = !b!d
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 82
BOR-
BOR-MI-
MI-CSET: Example (5)
Continuing with Step 4 we obtain
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 83
BOR-
BOR-MI-
MI-CSET: Example (6)
Applying Step 6 to the FS sets leads to the following
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 84
BOR-
BOR-MI-
MI-CSET: Example (7)
Summary
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 85
BOR-
BOR-MI-
MI-CSET: Example (8)
Obtained by applying Step 2 of BOR-CSET to an AND node
S tN3 = S tN1 ⊗ S tN2
S fN3 = (S fN1 × {t2}) ∪ ({t1} × S fN2) True constraint: {(t, t, t, f), (t, f, t, t)}
False constraint: {(f, t, t, f), (t, f, t, f), (t, t, f, t)}
N3
∧ True constraint: {(t, t, f), (f, t, t)}
False constraint: {(f, t, f), (t, f, t)}
N2
∨
∧ ∧
N1
a
b c !b d
True constraint: t
False constraint: f
Apply MI-CSET
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 86
Summary (1)
Most requirements contain conditions under which functions are to be
executed. Predicate testing procedures covered are excellent means to
generate tests to ensure that each condition is tested adequately.
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 87
Summary (2)
Usually one would combine equivalence partitioning, boundary value
analysis, and predicate testing procedures to generate tests for a
requirement of the following type:
Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 88