Unit Test 块覆盖率

Block:A sequence of non-branching statements; a linear sequence of code with no control flow route branchings.

Block coverage

Block coverage, sometimes known as line coverage, describes whether a block of code, defined as not having any branch point within (i.e. the path of execution enters from the beginning and exits at the end) is executed or not.

Block到底如何计算?
其实,我们说Block覆盖率是针对目标码而言,而不是源代码。这在Line Coverage中有提到过。一个Block是说一个机器码片段的基本控制流的单个进和单个出。因此,一个调用语句的使用可以看作是一个Blcok结束的标志。
Example:
int main()
{
1:    BasicClass A;
2:    int i = 10;
3:    if (i)
4:    {
5:       i = A.function();
6:    }
7:    return i;
}

在上面的例子中,你觉得会有几个Block?
一相当部分的人会觉得是3个。其实不然。
第一行中BasicClass类对构造函数和析构函数(之后)的调用,第5行中对function()的调用以及i返回值的分配。

 

参考:

http://www.51testing.com/?uid-264206-action-viewspace-itemid-129974

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值