批量运行VS代码覆盖工具

时间:2011-02-10 15:09:08

标签: visual-studio-2010 code-coverage

我提出了一个批处理文件,用于生成代码覆盖文件,如post中所述。

cl /Zi hello.cpp -link /Profile
vsinstr -coverage hello.exe
start vsperfmon /coverage /output:run.coverage
hello
vsperfcmd /shutdown

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

enter image description here

我必须手动运行vsperfcmd /shutdown才能完成它。 什么可能是错的?

2 个答案:

答案 0 :(得分:5)

这只是一个时间问题。

start vsperfmon /coverage /output:run.coverage命令在单独的进程中启动vsperfmon.exe。

同时,您的脚本继续运行hello。如果hello是一个非常简单的程序,它可能会在vsperfmon.exe运行并完全初始化之前执行并完成。如果您的脚本在显示器启动并运行之前点击vsperfcmd /shutdown,您将收到正在显示的错误。

vsperfcmd只是vsperfmon的控制器/启动器,因此您可以在批处理文件中专门使用它:

cl /Zi hello.cpp -link /Profile
vsinstr -coverage hello.exe
vsperfcmd /start:coverage /output:run.coverage
hello
vsperfcmd /shutdown

在这种情况下,对vsperfcmd的第一次调用将一直阻止,直到显示器启动并完全运行。

答案 1 :(得分:0)

为已使用IIS Express应用程序的已检测文件执行此操作: 从C:\Users\<your user>\Documents\IISExpress\config\applicationhost.config

获取网站名称
vsperfcmd /start:coverage /output:run.coverage
"c:\Program Files (x86)\IIS Express\iisexpress.exe" /site:"<that thing you got from applicationhost.config>"

浏览器可能会自动启动。点击代码,进行手动测试。

然后完成

vsperfcmd /shutdown