Logic Coverage
Predicate - an expression that evaluates to a boolean value
Clauses - predicates withtout logical operators
Logic Operators
: negation
: and
: or
: right arrow
: xor
: equivalence
Notations
: a set of predicates
: all caluses making up the predicates of
: caluses of the predicate
Coverages
Predicate Coverage (PC)
For each , TR contains two requirements
- evaluates to true
evaluates to false
Analogous to edge coverage on a CFG
- Very coarse grained
Caluse Coverage (CC)
For each , TR contains two requirements
- evaluates to true
- evaluates to false
Combinatorial Coverage (CoC)
For each , TR has test requirements for the clauses in
- Also known as multiple condition coverage
- Unscalable, since the number of test requirements while finite, grows exponentially.
Symbol for Clause and Predicate
For predicate and clause
: replaced by true
: replaced by false
e.g.
- If can never determine , then is redundant with respect to
- You can write without using
Constructing a Truth Table
If the major clause is , then the row in the truth table is testable for a if
Active Clause Coverage (ACC)
For each and making each caluse major, choose assignments for minor clauses , such that determines . TR has requirements for each : evaluates to true and evaluates to false.
- The s may be different when evaluates to true and evaluates to false.
- No restriction on the
General Active Clause Coverage (GACC)
For each and letting each clause be a major caluse, choose minor cluase value such that determines . TR contains two test requirements for each : evaluates to true and evaluates to false.
- Does not subsumes but subsumes
Correlated Active Cluase Coverage (CACC)
For each and letting each clause be major, choose minor clause values for such that determines . TR contains two requirements for each : evaluates to true and evaluates to false.
The values chosen for must cause to be true and for one value of and false for the other.
- Values chosen for must cause to be true for one value of and false for the other
- Must also satisfy GACC
- Must make true and false for each clause
Restricted Active Clause Coverage (RACC)
For each and letting each clause be major, choose minor clause values for such that determines . TR contains two requirements for each : evaluates to true and evaluates to false.
The values for each must be the same when is true and when is false
- Must have the same minor caluse in the test set for each major clause
- Harder to satisfy
Infeasibility
- A test requirement is infeasible if no test case can satisfy test requirement .
Could be caused by
- Predicate is unreachable in its context
- Method containing the predicate never assigns appropriate values to its variables to cause the desired caluse values
- A cluase never determines a predicate and you are trying to achieve an active cluase coverage criterion
Workarounds
- Satisfy feasible test requirements, dro pinfeasible test requirements
- If you can't satisfy a particular coverage criterion, use a looser criterion (e.g. settle for CACC if you can't satisfy RACC)
Achieving Logic Coverage
- Identify the predicates in the program fragement under test
- Figure out how to reach each of the predicates
- Make determine (for the active clause criteria$$
- Find values for variables to meet various criteria