0

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?

Jack
  • 2,153
  • 5
  • 28
  • 43
  • I haven't tested it, but the reason is probably correct. I know OpenCover has been tested with typemock http://stackoverflow.com/questions/6698290/can-opencover-be-used-with-typemock-isolator – Shaun Wilde Aug 10 '11 at 20:46

1 Answers1

1

The name of the profiler you need is probably the CLSID.

Try setting the environment variable to 1542C21D-80C3-45E6-A56C-A9C1E4BEB7B8

Shaun Wilde
  • 8,228
  • 4
  • 36
  • 56
  • That solved it - setting the environment variable to that ID, and ensuring that I did not use the -register:user argument. Thanks yet again for all your help Shaun - you've made a great piece of kit! – Jack Aug 11 '11 at 08:12
  • thanks - I'm glad it worked - testing with moles has been on my todo list for a while – Shaun Wilde Aug 11 '11 at 09:56
  • Glad I could help you cross that one off the todo list! One last thing (I hope) - is there a way to get OpenCover to return the same exit code as MSTest? I want the build to fail on the build server if there are failures in the tests, but at the moment the build is passing (I assume as OpenCover returns that it was successful?). – Jack Aug 11 '11 at 10:11
  • Just spotted this on GitHub - I'll follow https://github.com/sawilde/opencover/issues/27 so there's no need for you to say things twice :) – Jack Aug 11 '11 at 10:18