Logical Coverage Criteria

Most basic three
(1) Predicate Coverage (PC)
Each predicate should evaluate to both true and false.
(2) Clause Coverage (CC)
Each clause in predicate should evaluate to both true and false.
(3)    Combinatorial Coverage (CBC)
All combinations of clause values should be considered.

Let's use an example to illustrate the idea.
Suppose we have Java code segment:


We can abstract the predicate (x<y || flag ) && list.contains("red") to (a ∨ b) ∧ c.
So predicate: p= (a ∨ b) ∧ c, and clauses: a,b, and c.
(1) PC
Test suite={p=true,p=false}, we don't care about the values of a,b,c as long as p=true and p=false are satisfied.

(2) CC
In this case, a, b and c all have to evaluate to both true and false. The truth table is shown below.

 

    a         b         c

-----------------------------

    T

-----------------------------

    F

-----------------------------

               T        

-----------------------------

               F

-----------------------------

                          T

-----------------------------

                          F

-----------------------------

 

We do not care about the blank cells. So test suite={(T,T,T),(F,F,F)} can satisfy CC.

 

(3) CBC

 

All combinations must be tested. So there will eight test cases.

 

    a         b         c

-----------------------------

    T         T         T

-----------------------------

    T         T         F

-----------------------------

    T         F         T

-----------------------------

    T         F         F

-----------------------------

    F         T         T

-----------------------------

    F         T         F

-----------------------------

    F         F         T

-----------------------------

    F         F         F

-----------------------------

 

There are other more sophisticated coverage criteria to better test software.

 

Reference: Paul Ammann & Jeff Offutt "Introduction to software testing"

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值