NCover Desktop is a .NET code coverage tool.
This article explains how to link both the JustMock and the NCover profilers and have
passing unit tests with collected code coverage.
Important step: You must install NCover with turned off global profiling! Otherwise,
you will not be able to integrate it with the Telerik JustMock profiler.
For more details, follow
Linking JustMock and NCover Profilers
To use NCover along with the JustMock profiler, you will need to:
Configure your NCover project:
- MSTest (this points to an article from the NCover web site)
- NUnit (this points to an article from the NCover web site)
Then, you will have to register the NCover profiler.
Run an elevated Command Prompt (cmd.exe as administrator). Navigate to the NCover install folder
(by default: C:\Program Files\NCover v4 Desktop\) and execute the following line:
ncover use --reg
Continue by linking the profilers (depending on the NCover version you are using) from the JustMock Configuration tool:
This process 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, you will be able to collect the coverage data of your assemblies:
ncover run --project=proj -- "c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe"
/testcontainer:"C:\Program Files (x86)\Telerik\JustMock\Examples\CSExamples\JustMock.ElevatedExamples\bin\Debug\JustMock.ElevatedExamples.dll"
Note, JustMock elevated tests should pass now:
Finally, check if coverage has been collected for your assemblies.
To successfully unlink both profilers, you will need to:
Unlink both profilers, as shown here.
Unregister the NCover profiler with executing the following line in the command prompt:
ncover use --unreg
Visual Studio integration
Having the profilers linked must be enough for using both JustMock and NCover inside Visual Studio: