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?
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
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.
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