Code coverage in VS2013 show coverage of Test and not actual code

蹲街弑〆低调 提交于 2020-01-17 15:23:19

问题


I am following article for code coverage in VS 2013 http://msdn.microsoft.com/en-us/library/dd537628.aspx. It shows coverage of Test and not actual code.

I have selected unit test from Test explorer and click on Analyze Code Coverage -> Selected Test. Code coverage window is opened up at the bottom and It shows dll of unit test and its coverage and actual dll with code coverage is not shown.

Also, I looked into article http://msdn.microsoft.com/library/jj159523.aspx. Copied pdbs and dll into same location. In the code coverage window message was

Empty results generated: No binaries were instrumented. Make sure the tests ran, required binaries were loaded, had matching symbol files, and were not excluded through custom settings. For more information see http://go.microsoft.com/fwlink/?LinkID=253731"

Any idea about this?


回答1:


I have tried steps given in the link.

http://blogs.msdn.com/b/allendm/archive/2012/09/08/empty-coverage-file-with-profiler-related-errors-in-the-event-logs.aspx

Slight change if you are using VS 2013.

a) Environment variable VS120COMNTOOLS is set to \common7\tools

b) Regkey HKLM\SOFTWARE\Microsoft\VisualStudio\12.0\InstallDir is set to your \Common7\IDE\

c) covrun32.dll and covrun64.dll exist in "\Team Tools\Dynamic Code Coverage"

Removed VS110COMNTOOLS environment variable. These changes worked for me.




回答2:


I was able to resolve my issue. The reason why code coverage was not happening on my production DLL was: reason = "has_fixed_base". Once I changed this setting to: Yes (/DYNAMICBASE), the coverage started working.

It would help to check these steps:

  1. Open Project Properties
  2. go to Linker->Advanced page
  3. In that, check Randomized Base Address
  4. Change it to Yes (/DYNAMICBASE)

This should start code coverage.



来源:https://stackoverflow.com/questions/27836882/code-coverage-in-vs2013-show-coverage-of-test-and-not-actual-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!