询问者
Microsoft Visual Studio Premium 2012 怎样在单元测试中测试代码覆盖率

问题
全部回复
-
你先编译一下单元测试项目,确保没有编译错误。并且测试方法在“test explorer”窗口中已经被识别到。
然后,再去收集代码覆盖率。你的代码覆盖率是通过测试菜单下的选项收集的。对吧?
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
你用的VS2012的哪个版本?有没有安装最新的更新包,我记得应该是VS2012 update 5.
你有没有别的同样的VS2012环境试一试?如果你只是创建一个简单的单元测试也有这个问题吗?
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
我自己试着安装了同样的版本,好像是可以得。
要不你修复一下试试?
我是从这里下载的:
https://www.microsoft.com/en-hk/download/details.aspx?id=30654
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
正常我们是直接运行代码分析选项:
然后,他会执行测试,所以说你所谓的如果测试通过就有代码覆盖率,这个确实不能这么说,因为本身我们用的方式是直接获得代码覆盖率,然后他会执行test的而已。
我只是创建了一个空的native的单元测试,然后像上面的截图一样,在test explorer窗口选在分析代码覆盖率选项,然后我就能得到正确的结果。和你的步骤有不一样的地方吗?
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
应该和语言版本没有关系。
我虽然安装的是英文版本,但是我安装了中文的语言包,然后执行也是正常的。
所以可能问题还是在你的VS上,当然,我会重新搭建一个新的环境,然后直接安装中文版的VS2012试试(我会及时更新最新的消息的)。
另外,我建议你修复或者重新安装一下VS2012。从这里下载:
https://www.microsoft.com/en-hk/download/details.aspx?id=30654
另外,确保没有编译错误并且在debug模式下,你可以clean并build你的项目,查看一下VS error list和output窗口没有error信息。另外dll文件正确的生成,你可以删除bin\debug文件夹,然后重新编译项目,确保dll会重新生成。运行代码覆盖率试试。
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已编辑 Jack Zhai-MSFTMicrosoft contingent staff, Moderator 2016年4月13日 9:46
-
我安装了中文版的VS2012,也是正常的,所以应该和语言版本没关系。要不你还是修复一下你的VS2012吧,另外最好安装VS2012 Update 5.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
哦,我忘记了,VC++的是没有bin文件夹的,正常的项目dll文件都是存在:
C:\Users\Admin\Documents\Visual Studio 2012\Projects\UnitTest1\Debug
你的项目是存在默认的VS存储项目的路径下的吗?有没有以管理员身份打开VS试试?
关闭VS,打开项目的路径,删除.suo 文件, 重启电脑,重新打开项目的.xxproj 文件,重新分析一下代码覆盖率。以前有遇到过suo文件影响代码覆盖率的。
如果还是不行,你用的是什么windows 环境,我在windows 10 64位机器一切都是正常的。你重新安装2015有没有遇到错误信息?
把项目复制到桌面或者D盘,然后重新打开编译,还是不能收集覆盖率吗?
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已编辑 Jack Zhai-MSFTMicrosoft contingent staff, Moderator 2016年4月18日 11:07
-
你有没有在别的机器环境上试一下?如果别的机器上好用,我觉得还是你的环境的问题。
目前我只有windows 8.1和windows 10的机器环境,要不我明天搭建一个windows 7帮你测试一下吧?
我个人觉得windows 7上应该也是可以的。对了,你如果创建C#的单元测试,然后执行代码覆盖率,能收集到吗?
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
我在一台windows 7上安装了中文版本的VS2012:
https://www.microsoft.com/zh-CN/download/details.aspx?id=30654
然后创建了一个空的VC++本地测试项目,然后手机代码覆盖率,一切都是正常的,所以,我觉得还是你的环境的问题。
建议你卸载重新下载一下官方的VS2012,然后重新安装试试。有可能是安装出了问题。
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.