我有以下 C++ 代码.
I have the following C++ code.
#include <iostream>
using namespace std;
int testfunction(int input)
{
if (input > 0) {
return 1;
}
else {
return 0;
}
}
int main()
{
testfunction(-1);
testfunction(1);
}
我编译它以获得执行
cl /Zi hello.cpp -link /Profile
然后,我检测执行并生成 .coverage 二进制文件.
Then, I instrument the execution and generated the .coverage binary.
vsinstr -coverage hello.exe
start vsperfmon -coverage -output:mytestrun.coverage
vsperfcmd -shutdown
当我在 VS2010 中打开覆盖文件时,我没有得到任何结果.
When I open the coverage file in VS2010, I got nothing in its results.
可能有什么问题?我按照这篇文章中的说明进行操作.
What might be wrong? I followed the instructions in this post.
你需要在监视器启动后运行你的程序:
You need to run your program after the monitor starts:
当您运行第 3 步时,您应该会在 vsperfmon.exe 中看到一些通知,提示 hello.exe 已启动.
When you run step 3, you should see some notification in vsperfmon.exe that hello.exe has started.
如果您计划进行多次测试运行,则只需运行步骤 2-4.换句话说,您只需要在二进制文件(步骤 1)构建后对其进行一次检测.
If you plan on doing multiple test runs, you only need to run steps 2-4. In other words, you only need to instrument your binary (step 1) once after it's built.
这篇关于如何在命令行中使用 MS 代码覆盖工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!