如果我正在使用MSTest,有没有办法测试visual studio中的代码覆盖率?或者我必须购买NCover?
如果微软没有提供内置工具来进行代码覆盖,那么NCover Enterprise是否物有所值,或者旧的测试版是否足够好?
编辑:VS产品的描述以及哪些包括代码覆盖率 https://www.visualstudio.com/vs/compare/
如果您的VS版本不支持,可以使用TestDriven.NET(http://testdriven.net/).
我运行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()有四个街区.
我从这篇文章得到了提示.
我想出了一个批处理文件是写在这个生成的代码覆盖率文件后.
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手动运行才能完成它.可能有什么问题?