NCover Documentation

Collector Optimize

At NCover, we've been learning from our experience with users regarding coverage collection and syncing. As part of our efforts to continually improve performance and the overall user experience we've condensed our findings into a few standard recommendations designed to optimize Collector performance.

Please note that the following best practices use NCover command line functions, which are ideally run as part of a script each time coverage is to be collected.

Collector Optimize:

  1. Set the NCOVER_BUILD_ID variable globally. When your test process begins, the build variable will be part of the test environment and all of your coverage executions will be assigned that build ID. Check out SetX, which is a good utility for modifying any kind of variables:

  2. Run the NCover Analyze command before starting your unit test, manual test, build script, etc. Since Analyze is pre-processing the metadata, this removes some of the coverage overhead at runtime, which generally results in faster profiling. In the directory where your DLLs are located, run one of the following commands (depending on the bitness of your source code):

    NCover Analyze32 your.code.*.dll --force-reload (this is a suggested pattern match, otherwise you can use NCover Analyze32 *.dll to process all assemblies) --force-sync

    For a 64-bit process:

    NCover Analyze64 your.code.*.dll --force-reload --force-sync

    Note that after the first time NCover Analyze is run, -- force-reload should not be used. NCover Analyze will automatically process any new assemblies, but using --force-reload causes every assembly to be processed each time the Analyze command is run. The --force-sync should be used each time, so that the data will be sent to Code Central.

  3. On Collector, disable syncing to Code Central before coverage collection starts, and re-enable syncing after tests are completed. This will keep the data collection process separate from the data syncing, and should improve overall performance:

    NCover Sync-Disable --all

    NCover Sync-Enable --all

  4. Merge coverage data locally before syncing, so that all coverage data is sent at the same time:

    ncover merge --project="YourProject" --buildId="Test" --consolidate-delete

  5. Generate the Coverage Summary report on Code Central after the coverage data is synced using the build Id you assigned above:

    ncover.exe report --project="NUnitLocal" --execution="BuildId" --file="C:\YourPath\CovergeReport.html"

So, your Collector build script will look like this:

  • Run NCover Analyze.
  • Run NCover Sync-Disable --all
  • Run your tests
  • Run NCover Merge on build ID
  • Run NCover Sync-Enable --all

Note: the Merge --consolidate-delete option combines all executions and then deletes the originals to save space and reduce the amount of data to be synced to Code Central. If you need to keep the individual executions, do not use the --consolidate-delete option.

We recommend running these NCover commands manually the first time, which makes them easier to troubleshoot. Once you’ve verified the commands are working as expected, add them to a script.

We hope this information is helpful, and please feel free to reach out to us at if you have any questions about this process.

If you still need technical assistance, we can help:

Submit A Support Ticket