code coverage

Code coverage is a measure used in software testing. It describes the degree to which the source code of a program has been tested. It is a form of testing that inspects the code directly and is therefore a form of white box testing[1].

 

Basic coverage criteria

There are a number of coverage criteria, the main ones being:[3]

  • Function coverage - Has each function (or subroutine) in the program been called?
  • Statement coverage - Has each node in the program been executed?
  • Branch coverage - Has every edge in the program been executed?
  • Decision coverage (also known as branch coverage) - Has each control structure (such as an IF statement) evaluated both to true and false?
  • Condition coverage (or predicate coverage) - Has each boolean sub-expression evaluated both to true and false? This does not necessarily imply decision coverage.
  • Condition/decision coverage - Both decision and condition coverage should be satisfied.

代码覆盖率,简单来说代码被执行过,就是“覆盖过”,如果一段程序运行了一组测试用例之后,100%的代码被执行了,那么是否就说明再也不用写新的测试用例了呢?

答案是否定的。

(1)不同代码是否执行,有很多组合,一行代码被执行过,没有问题,并不表明这一行程序在所有可能条件的组合下都能正确无误地运行。

(2)代码覆盖不能测出还没有写的代码(缺少的逻辑)导致的错误。

比如:

a. 没有检查过程调用的返回值;

b. 没有释放资源。

(3)代码覆盖不能测出效能问题。

(4)代码覆盖不能测出时序问题,由时序导致的程序错误(例如:线程之间的同步)。

(5)代码中和用户界面相关的功能不能简单地以代码覆盖率来衡量优劣。

reference:

1. http://book.51cto.com/art/200902/108511.htm

2. http://emma.sourceforge.net/intro.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值