前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Tool之CoverageScope

Tool之CoverageScope

作者头像
Taishan3721
发布2021-11-12 18:33:23
2980
发布2021-11-12 18:33:23
举报
文章被收录于专栏:这里只有VxWorks

欢迎关注VxWorks567

如转发 请标明出处!

ScopeTools里还有个成员叫做CoverageScope,现改名为Code Coverage Analyzer。不过Vx7里已经不支持它了(以及Data Monitor)。这是一个运行时的代码覆盖度测试工具。顾名思义,这个工具可以用于测试代码是否执行过。它可以检测已调用函数或已执行语句的百分比,并记录未执行的代码

You can configure coverage to gather and display test data on the following aspects:

  1. function execution — percentage executed; which ones were (not) executed by the test? how often?
  2. function exit points — percentage used; which ones were (not) used by the test? how often?
  3. code blocks — percentage executed; which ones were (not) executed by the test? how often?
  4. decisions — percentage tested; which ones were (not) tested? how often? Were both the TRUE and FALSE branches of a decision statement tested?
  5. conditions (subexpressions)— percentage tested; which ones were (not) tested? how often? was each Boolean subexpression separately evaluated to both TRUE and FALSE?
  • You can jump from the Code Coverage Analyzer output directly to the source code to help you understand why something is not being covered.
  • You can generate fully configurable HTML output reports with selectable coverage data, as well optionally including the output graphs and source files (rendered in HTML with syntax highlighting).
  • You can save and export coverage analysis files to CSV files for use in spreadsheet applications.

重点是看看怎么用吧,随便写个例子,多包含一些分支,例如

代码语言:javascript
复制

static void child1(int num)
    {
    switch(num)
        {
        case 1:
            break;
        case 2:
            break;
        case 3:
            break;
        case 4:
            break;
        case 5:
            break;
        default:
            break;
        }
    }
static void child2(int num)
    {
    if(num > 0)
        {
        }
    else if(num == 0)
        {
        }
    else
        {
        }
    }
static void child3(int num)
    {
    while(num > 0)
        {
        num--;
        }
    }

void testCoverage()
    {
    int i;

    for(i=0; i<4; i++)
        child1(i);
    child2(0);
    child2(1);
    child3(5);
    }

这是它的测试效果

具体操作流程如下

  • 新建一个DKM,把这个例子加进去
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2021-11-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 这里只有VxWorks 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档