NCover
NCover Desktop is a .NET code coverage tool.
This article explains how to link the Telerik® JustMock and NCover profilers and have passing unit tests with collected code coverage.
Configuring NCover
You must install NCover with global profiling turned off. Otherwise, you will not be able to integrate it with the TelerikJustMock profiler.__
For more details, follow this link: https://www.ncover.com/support/docs/extras/command-line/set-install-dir.
Linking JustMock and NCover Profilers
To use NCover along with the JustMock profiler, you will need to:
-
Configure your NCover project:
-
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
-
Link the profilers (depending on the NCover version you are using) from the JustMock Configuration tool:
This process is better described here.
-
Set the JUSTMOCK_INSTANCE environment variable to "1".
Do this by inserting the following line in the previously opened command prompt:
SET JUSTMOCK_INSTANCE=1
-
Then, you will be able to collect the coverage data of your assemblies.
For example:
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"
JustMock elevated tests should pass now:
-
Finally, check if coverage has been collected for your assemblies.
Note
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: