Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Logic Coverage Criteria: Making clauses
determine predicate
Meenakshi D’Souza
International Institute of Information Technology
Bangalore.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Recap: Logic coverage criteria and their subsumption
Combinatorial
Coverage (CoC)
Restricted Active Restricted Inactive
Clause Coverage Clause Coverage
(RACC) (RICC)
Correlated Active General Inactive
Clause Coverage Clause Coverage
(CACC) (GICC)
General Active
Clause Coverage
(GACC)
Clause Predicate
Coverage (CC) Coverage (PC)
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Test cases for predicate, clause and combinatorial coverage
Test cases for satisfying TRs for predicate, clause and
combinatorial coverage are easy to define.
As long as a predicate or a clause is not valid/not a
contradiction, we can find test cases to achieve predicate
coverage and clause coverage.
For combinatorial coverage, test cases will correspond to all
the values in the truth table.
Need to identify the correct predicates and pass them to a
SAT/SMT solver to check if the predicate is satisfiable.
If yes, the solver can provide satisfying assignments which can
be used as test cases.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Getting the logical predicates correct
x := 0;
if (x<y)
The usual problem of
{
reachability (RIPR criteria)
y := y+5; needs to be solved for writing
x := x+3; test cases.
if (y<15) For simple cases, we can
{ manually solve this.
--- ; In general, symbolic execution
-error- ; can be used to solve this
--- ; problem.
}
}
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Test cases for ACC and ICC criteria
For the various ACC criteria, we have to make the clause
chosen as major clause determine a predicate.
There are several ways of doing this. We discuss one approach
here.
Using the resulting predicates, we can write test cases for the
various ACC criteria.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Making a clause determine a predicate
Consider a predicate p with a clause c.
Let
pc=true represent the predicate p with every occurrence of c
replaced with true, and
pc=false represent the predicate p with every occurrence of c
replaced with false.
Not that neither pc=true nor pc=false contains any occurrence
of c.
Define pc = pc=true ⊕ pc=false , ⊕ represents the exclusive or
operator.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Making a clause determine a predicate
pc describes the exact conditions under which the value of c
determines p.
Clauses in pc take values such that pc is true: c determines p
(in terms of truth values).
Clauses in pc take values such that pc is false: p is
independent of c (in terms of truth values).
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Making a clause determine a predicate: Examples
Consider p = a ∨ b.
Then,
pa = pa=true ⊕ pa=false (1)
= (true ∨ b) ⊕ (false ∨ b) (2)
= true ⊕ b (3)
= ¬b (4)
For major clause a to determine p, the only minor clause b
must be false.
Symmetrically, pb = ¬a.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Making a clause determine a predicate: Examples
Consider p = a ∧ b.
Then,
pa = pa=true ⊕ pa=false (5)
= (true ∧ b) ⊕ (false ∧ b) (6)
= b ⊕ false (7)
= b (8)
For major clause a to determine p, the only minor clause b
must be true.
Symmetrically, pb = a.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Making a clause determine a predicate: Examples
Consider p = a ≡ b.
Then,
pa = pa=true ⊕ pa=false (9)
= (true ≡ b) ⊕ (false ≡ b) (10)
= b ⊕ ¬b (11)
= true (12)
For any value of b, a determines p without regard to the value
for b.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
ICC and predicates with ⊕ and ≡
For a predicate p where the value of pc for a clause c turns
out to be true, ICC criteria are infeasible with respect to c.
Typically, ICC criteria are likely to result in infeasible test
requirements when applied to predicates with ≡ or ⊕
operators.
Symmetrically, if a predicate p has a clause c such that pc
evaluates to false, ACC criteria are infeasible for p with
respect to c.
Basically, the clause c is redundant; predicate p can be
written without it.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Redundant clause in a predicate: Example
Consider the predicate p = a ∧ b ∨ a ∧ ¬b. This is just p = a.
Computing pb , we get
pb = pb=true ⊕ pb=false (13)
= (a ∧ true ∨ a ∧ ¬true) ⊕ (a ∧ false ∨ a ∧ ¬false)
(14)
= (a ∨ false) ⊕ (false ∨ a) (15)
= a⊕a (16)
= false (17)
It is impossible for b to determine p.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Clauses determining a predicate: More examples
Consider p = a ∧ (b ∨ c).
Then,
pa = pa=true ⊕ pa=false (18)
= (true ∧ (b ∨ c) ⊕ (false ∧ (b ∨ c)) (19)
= (b ∨ c) ⊕ false (20)
= b∨c (21)
a determines p when b ∨ c is true.
Three choices make b ∨ c true:
(b = c = true), (b = true, c = false), (b = false, c = true).
For CACC: Pick one pair when a is true and another when a is
false.
For RACC: Choose the same pair for both values of a.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Clauses determining a predicate: More examples
Consider p = a ∧ (b ∨ c).
Then,
pb = pb=true ⊕ pb=false (22)
= (a ∧ (true ∨ c) ⊕ (a ∧ (false ∨ c)) (23)
= (a ∧ true) ⊕ (a ∧ c) (24)
= a ⊕ (a ∧ c) (25)
= a ∨ ¬c (26)
Symmetrically, pc is a ∨ ¬b.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
TRs for ACC criteria
ACC criteria can get complicated for certain predicates in
terms of finding TRs and subsequently, satisfying test cases.
We walk through an example illustrating how to find final set
of TRs and then, test cases for ACC criteria.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
TRs for ACC criteria: Example
Consider the predicate p = (a ∨ b) ∧ c.
We first give the truth table for p.
a b c (a ∨ b) ∧ c
1 T T T T
2 T T F F
3 T F T T
4 T F F F
5 F T T T
6 F T F F
7 F F T F
8 F F F F
pa ¬b ∧ c
Clauses for pa , pb and pc are given below. pb ¬a ∧ c
pc a∨b
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
TRs for GACC criteria: Example
TR for GACC: Each major clause be true and false, minor
clauses be such that major clause determines the predicate.
TR for GACC: {(a = true ∧ pa , a = false ∧ pa ), (b =
true ∧ pb , b = false ∧ pb ), (c = true ∧ pc , c = false ∧ pc )}.
The following table gives true/false values for TR for GACC:
a b c p
a = true ∧ pa T F T T
a = false ∧ pa F F T F
b = true ∧ pb F T T T
b = false ∧ pb F F T F
c = true ∧ pc T F T T
c = false ∧ pc F T F F
First and fifth rows are identical, second and fourth rows are
identical. Only four tests are needed to satisfy GACC.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
TRs for other ACC: Example
Similarly, we can compute TR for the example for CACC and
RACC criteria.
Exercise: Compute CACC, show that CACC is the same as
GACC.
CACC is considered good for practical use.
Logic Coverage Criteria Clause determining a predicate Finding correct TRs for ACC criteria
Credits
Part of the material used in these slides is derived from the
presentations of the book Introduction to Software Testing, by
Paul Ammann and Jeff Offutt.