相关疑难解决方法(0)

MSTest代码覆盖范围

如果我正在使用MSTest,有没有办法测试visual studio中的代码覆盖率?或者我必须购买NCover?

如果微软没有提供内置工具来进行代码覆盖,那么NCover Enterprise是否物有所值,或者旧的测试版是否足够好?

编辑:VS产品的描述以及哪些包括代码覆盖率 https://www.visualstudio.com/vs/compare/

如果您的VS版本不支持,可以使用TestDriven.NET(http://testdriven.net/).

.net c# testing tdd code-coverage

21
推荐指数
3
解决办法
3万
查看次数

使用VS2010进行代码覆盖的块

我运行C++代码以获得代码覆盖率结果,如本文所述.

#include <iostream>
using namespace std;

int testfunction(int input)
{
    if (input > 0) {
        return 1;
    }
    else {
        return 0;
    }
}

int main()
{
    testfunction(-1);
    testfunction(1);
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

代码覆盖率结果表明main()中有三个块,testfunction()中有四个块.该块意味着什么?主/ testfunction中有3/4块怎么样?

添加

当我修改代码如下,

int main()
{
    testfunction(1);
    testfunction(1);
}
Run Code Online (Sandbox Code Playgroud)

或如下

int main()
{
    testfunction(-1);
    testfunction(-1);
}
Run Code Online (Sandbox Code Playgroud)

我有这个结果.

在此输入图像描述

似乎testfunction()有四个街区.

  1. 功能条目
  2. 如果阻止
  3. 其他块
  4. 条件

我从这篇文章得到了提示.

profiler profiling code-coverage visual-studio-2010

7
推荐指数
1
解决办法
2362
查看次数

批量运行VS代码覆盖工具

我想出了一个批处理文件是写在这个生成的代码覆盖率文件.

cl /Zi hello.cpp -link /Profile
vsinstr -coverage hello.exe
start vsperfmon /coverage /output:run.coverage
hello
vsperfcmd /shutdown
Run Code Online (Sandbox Code Playgroud)

但是,当我运行批处理文件时,我收到此错误消息.

在此输入图像描述

我必须vsperfcmd /shutdown手动运行才能完成它.可能有什么问题?

code-coverage visual-studio-2010

6
推荐指数
1
解决办法
2504
查看次数