OpenCover is an open source code coverage tool for .NET 2 and above.
OpenCover is most commonly used to gather coverage data of code that is being exercised by unit testing
(i.e. nunit, mstest etc.).
This article explaines how to integrate Telerik JustMock with OpenCover.
Start by registering the OpenCover profiler. Run cmd.exe as Administrator and execute the following lines:
regsvr32 "c:\Program Files (x86)\OpenCover\x64\OpenCover.Profiler.dll"
regsvr32 "c:\Program Files (x86)\OpenCover\x86\OpenCover.Profiler.dll"
You may need to change the above paths if OpenCover is deployed somewhere else on your machine.
Once the OpenCover.Profiler.dll is registered, you must link it with the JustMock profiler:
This is better described here.
Furhter, you will need to set the JUSTMOCK_INSTANCE environment variable to "1".
Do this by inserting the following line in the previously opened command prompt:
Then collect the coverage data of your assemblies:
"C:\Program Files (x86)\OpenCover\OpenCover.Console.exe" -mergebyhash
–target:"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe"
Continue by generating a coverage report (for example, using the ReportGenerator), and checking the test results.
If everything is set up as described, your elevated JustMock tests must pass: