NCover support with Moles

☆樱花仙子☆ 提交于 2019-12-02 07:11:08

问题


In our project we use NCover to measure our code coverage. If we measure tests which uses Moles the code coverage for those classes are not measured (0%). This has something to do with both Moles and NCover using the .NET profiler. After some searching on the internet I tried the following in command prompt without any result:

set COR_PROFILER={3FB1CC1E-1C17-4A37-9C18-BF3DB8F10E46} moles.runner.exe /pi:Dispatch /r:"C:\Program Files\NCover\NCover.Console.exe" "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe" /args:/testcontainer:..\Bin\TestLib.dll"

The number behind the COR_PROFILER is the NCover.Lib.x86.dll GUID which I previously registered with regsvr. Also adding COR_ENABLE_PROFILING=1 as env.var doesn't help.

Is there anyone who got this profiler chaining working or has experience with .NET profiler chaining?


回答1:


I dug around and found a way to use NCover in at least one simple example using Moles context. Check out this thread: http://www.ncover.com/forum/show_topic?id=1191




回答2:


Ruud,

Unfortunately, Moles and NCover are incompatible at this time. The problem lies in the fact that NCover sets up some environment vars, which Moles subsequently resets for its own use during the profiling session. It's definitely something that needs to be tackled. You might try asking the folks at Microsoft to consider a workaround for this issue.




回答3:


Have you tried the CLRMONITOR_EXTERNAL_PROFILERS environment variable?

set CLRMONITOR_EXTERNAL_PROFILERS={3FB1CC1E-1C17-4A37-9C18-BF3DB8F10E46}

And then run ncover to call mstest as normal you would otherwis

I used this technique successfully with OpenCover see No Coverage for Moles Tests on x64 Windows Server 2003



来源:https://stackoverflow.com/questions/5885612/ncover-support-with-moles

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