Tool之CoverageScope

2021-11-12 18:33:23 浏览数 (1)

欢迎关注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,把这个例子加进去

0 人点赞