问题
I have been getting used to OpenCover over the past few days, and have I noticed that tests using Moles do not generate any Coverage information.
I have created a small solution to isolate the problem, and have found that code coverage is generated only for tests that do not have the [HostType("Moles")]
attribute.
Reading around I have found this and this which seem to be NCover equivalents of my problem. They say that it is something to do with Moles running a profiler as well as the coverage tool, and that there is an environment variable CLRMONITOR_EXTERNAL_PROFILERS
that can be set to allow multiple profilers to run at the same time as Moles - I think that this is where the solution lies, but I'm not 100% sure.
I guess that the variable's value would be the name of the OpenCover profiler - does anyone know this name?
Has anyone managed to get OpenCover running with Moles? Can it be done?
回答1:
The name of the profiler you need is probably the CLSID.
Try setting the environment variable to 1542C21D-80C3-45E6-A56C-A9C1E4BEB7B8
来源:https://stackoverflow.com/questions/7013990/no-code-coverage-information-for-tests-using-moles