0% found this document useful (0 votes)
20 views88 pages

08 Requirements Based Predicate Testing One Slide

Uploaded by

Nidhish Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views88 pages

08 Requirements Based Predicate Testing One Slide

Uploaded by

Nidhish Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 88

Requirements-based Test Generation

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

Test generation from predicates

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.

Conditions guard actions


– For example,
if condition then action
is a typical format of many functional requirements

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.

The following predicate represents the condition part of the statement


pr: (printerstatus = ON) ∧ (printertray != empty)

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.

Negation is also denoted by placing a bar over a Boolean expression.


such as in (a ∧ b)

We also write ab for a ∧ b and a + b for a ∨ b when there is no confusion.

Singular Boolean expression: When each literal appears only once.


– Example: (a ∧ b ∨ !c)

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).

Conjunctive normal form (CNF): Product of sums:


e.g., (p + q)(r + s)(a + c).
Any Boolean expression in DNF can be converted to an equivalent
CNF and vice versa.
– e.g., CNF: (p + !r)(p + s)(q + !r)(q + s) is equivalent to
DNF: (pq + !rs)

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

Root node (AND-node)

<
!
(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?

Suppose that the specification of a software module requires that an


action be performed when the condition (a < b) ∨ (c > d) ∧ e is true.

Here a, b, c, and d are integer variables and e is a Boolean variable.

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>

The fault in pi is not revealed by t1 as both pc and pi evaluate to false


when evaluated against t1

However, the fault is revealed by t2 as pc evaluates to true and pi to false


when evaluated against t2

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, <, =, >}

A BR symbol is a constraint on a Boolean variable or a relational


expression

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.

For example, the constraint t (true) is infeasible for the predicate


(a > b) ∧ (b > d) if it is known that d > a

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

A predicate constraint C for predicate pr is a sequence of (n + 1) BR


symbols, one for each Boolean variable or relational expression in pr.
When clear from context, we refer to “predicate constraint” as simply
constraint.

Test case t satisfies C for predicate pr if each component of pr satisfies the


corresponding constraint in C when evaluated against t.
– Constraint C for predicate pr guides the development of a test case for pr (i.e.,
it offers hints on what the values of the variables should be for pr to satisfy C)

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, =, >)

The following test case satisfies C for pr


<b = true, r = 1, s = 1, u = 1, v = 0>

The following test case does not satisfy C for pr


<b = true, r = 1, s = 2, u = 1, v = 2>

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

C is referred to as a true constraint when pr(C) is true and a false


constraint otherwise

A set of constraints S is partitioned into subsets S t and S f, respectively,


such that for each C in S t, pr(C) = true, and for any C in S f, pr(C) = false.

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

T is referred to as a BOR-adequate test set and sometimes written as TBOR

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

T is referred to as a BRO-adequate test set and sometimes written as TBRO

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

T is referred to as a BRE-adequate test set and sometimes written as TBRE

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

Tx is said to guarantee the detection of faults in pf if for some t ∈ Tx,


pr(t) ≠ pf (t)

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

Each predicate is evaluated against the three test cases in T


– Each faulty predicate evaluates to a value different from that of pr for at least
one test case in T

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

In fact, if we remove t2 from T, then T is no longer BOR adequate


because the constraint (t, f ) is not satisfied

We can verify that if any column in the previous table is removed,


at least one of the faulty predicates will be left indistinguishable
by the tests in the remaining two columns

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}

The onto product of two sets A and B is defined as


for finite sets A and B, A ⊗ B is a minimal set of pairs (u, v)
such that {(u, v) | u ∈ A, v ∈ B, and each element of A appears
at least once as u and each element of B appears once as v}

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

First, generate syntax tree of pr

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

SN1= {(t), (f)} SN2= {(t), (f)}

Notice that N1 and N2 are direct descendents of N3 which is an


AND-node

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.

SN3 = {(t, t), (f, t), (t, f)}


SN3t = SN1t ⊗ SN2t = {(t)} ⊗ {(t)} = {(t, t)} False constraint
N3 ∧

SN3f = (SN1f × {t2}) ∪ ({t1} × SN2f ) N1 N2


= ({(f)} × {(t)}) ∪ ({(t)} × {(f)}) a<b c>d
{(t), (f)} {(t), (f)}
= {(f, t)} ∪ {(t, f)}
= {(f, t), (t, f)}

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.

SN3 contains a sequence of three constraints and hence


we get a minimal test set consisting of three test
cases. Here is one possible test set.

TBOR = {t1, t2, t3}


SN3 = {(t, t), (f, t), (t, f )}
t1 = < a = 1, b = 2, c = 4, d = 5 > N3 ∧
t2 = < a = 1, b = 0, c = 4, d = 5 >
t3 = < a = 1, b = 2, c = 3, d = 2 >
N1 N2
a<b c>d
{(t), (f)} {(t), (f)}

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)

S6t = {(t, f, f), (f, f, t)}


S6f = {(f, f, f), (t, t, f)}
S4t = {(t, f)} N6
S4f = {(f, f), (t, t)}
N4
∧ N5 S5t = {t}
r>s S5f = {f}
N1 S3t = {f}
N3
a+b<c ! S3f = {t}
S1t = {t}
S1f = {f} p N2 S2t = {t}
S2f = {f}

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

N1 N3 True constraint {>}


a+b<c !
False constraint {<, =}
True constraint {<}
p N2
False constraint {>, =}
True constraint {t}
False constraint {f}

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)

True constraint {(<, f )}


N6
False constraint {(>, f ), (=, f ), (<, t)}

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, =)}

S tN6 = (S tN4 × {(fN5)}) ∪ ({(fN4)} × S tN5)


= ({(<, f)} × {(=)}) ∪ ({(>, f)} × {(>)})
= {(<, f, =)} ∪ {(>, f, >)}
= {(<, f, =), (>, f, >)}

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

True constraint {(<, f )}


N4
False constraint {(>, f ), (=, f ), (<, t)} ∧ r>s
N5

N1 True constraint {>}


N3
a+b<c ! False constraint {<, =}
True constraint {<}
p N2
False constraint {>, =}
True constraint {t}
False constraint {f}

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

BRO 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)

A sample test set (TBRO) that satisfies the BRO constraints

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

Singular Boolean expression: When each literal appears only once


– Example (a ∧ b ∨ !c)

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

Expression ei is considered a singular component of E if and only if ei is


singular and is mutually singular with each of the other elements of E

Expression ei is considered a non-singular component of E if and only if


it is non-singular and is mutually singular with each of the remaining
elements of E

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

Predicate (pr) DNF Mutually singular components in pr

ab(b + c) abb + abc a; b(b + c)

a(bc + bd) abc + abd a; (bc + bd)

a(bc + !b + de) abc + a!b + ade a; bc + !b + de

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

Step 1: Construct a constraint set Te1 for e1 that makes e1 true.


Similarly construct Te2 for e2 that makes e2 true
Te1 = {(t, t, t, t), (t, t, t, f )}
Te2 = {(t, f, t, t), (t, f, f, t)}

– 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 = ∅

– There are no common constraints between Te and Te in our example.


1 2
Hence we get
TSe = {(t, t, t, t), (t, t, t, f )}
1

TSe = {(t, f, t, t), (t, f, f, t)}


2

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

of tests that make E true and cover each term of E as follows

S tE = {(t, t, t, f ), (t, f, f, t)}

– 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

e11 = !abc e21 = a!bc e31 = ab!c

e12 = !a!bd e22 = abd e32 = a!b!d

From each term e above, derive constraints Fe that make e true.


We get the following six sets

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)

Step 6: Now construct S fE by selecting one constraint from each FSe

SfE = {(f, t, t, f ), (t, f, t, f ), (t, t, f, t), (f, f, t, t)}

Step 7: Now construct SE = S tE ∪ S fE

SE = {(t, t, t, f ), (t, f, f, t), (f, t, t, f ), (t, f, t, f ), (t, t, f, t), (f, f, t, t)}

Note: Each constraint in S tE makes E true and each constraint in S fE


makes E false

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

Fu1 = {(f, t, t), (f, t, f )} Fu2 = {(t, f, t), (t, f, f )}


Fv1 = {(t, t, t), (t, f, t)} Fv2 = {(f, t, f ), (f, f, f )}

Next we apply Step 5 to the F constraint sets to obtain


FSu1 = {(f, t, f )} FSu2 = {(t, f, t), (t, f, f )}
FSv1 = {(t, f, t)} FSv2 = {(f, t, f ), (f, f, f )}

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

Sfe2 = {(f, t, f ), (t, f, t)}

Combing the true and false constraint sets for e2 we get

Se2 = {(t, t, f ), (f, t, t), (f, t, f ), (t, f, t)}

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

S te1 = {(t)} S fe1 = {(f )} from BOR-CSET procedure


S te2 = {(t, t, f ), (f, t, t)} S fe2 = {(f, t, f ), (t, f, t)} from MI-CSET procedure

We now apply Step 2 of the BOR-CSET procedure to obtain the constraint


set for the entire expression E

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:

if condition then action 1, action 2, …action n;

apply predicate testing or BVA

apply equivalence partitioning, BVA, etc., and


predicate testing if there are nested conditions

Requirements-based Test Generation for Predicate Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 88

You might also like