NCover Documentation

Covering a Windows Service

NCover Desktop runs as a service, so it's already monitoring, ready to cover any .NET code executing on your machine.

This ability to gather data globally is key to understanding how to leverage the power of NCover Desktop. When setting up any project the first question you should ask is, What process do I want to cover? If NCover can find the service that's exercising your code, it can collect coverage data.

1. Creating a Project

From the Home view of Desktop, click Add New to open the "Create a New Project" window.

2. Settings

From the "General Settings" tab, name the project.

Finding the right process to profile is the key to successful coverage. Profiling is accomplished with match rules, so let's talk about how they work and the options for creating them.

In the Processes to monitor: section, specify a Type and a Value to create a Match Rule for the IIS process.

You could use either Type of rule here -- an Exe ("CustMailer.exe") or a Regex ("CustMail*.").

3. Auto-Configure

Another option is to click on the Auto-Configure button and let NCover create match rules for you.

The General Settings tab will switch to the Auto-Detection view and start monitoring for .NET processes as soon as you click on Auto-Configure.

Start your application, and the executables and assemblies that are being loaded will display in the detection window.

Review the list and uncheck any items that shouldn't be covered.

Note that Desktop automatically excludes some common code, such as the Accessibility.dll

Click Stop Detection when your selections are complete, and Restart Detection, if necessary, to re-capture your processes/assemblies.

Click Show Match Rules to view the processes you selected.

Note: If you have already saved project settings, a pop-up will alert you that confirming the configuration will reset the Match Rules and Pre-Coverage filter conditions, but these changes are not automatically saved. You will still need to press Save to commit the changes for this project.

Click Save to accept these selections, or Auto-Configure to start over.

Note: "Include" filters will be automatically created based on the detected modules that you selected. You can review the filters on the "Pre-Coverage Filter" tab.

4. Collect Coverage

When your project selections are complete, start or re-start IIS and run your manual or automated tests.

Go to the Home page and you'll see that the light beside your enabled project is pulsing green to indicate coverage is being collected.

Immediately to the right of your project name, the Modules Collecting counter displays the number of modules being profiled in the current execution of your project. The number will fluctuate while coverage is running, but the counter should eventually disappear when profiling is complete.

When your tests are complete, don't forget to stop or cycle the service to end profiling and allow NCover Desktop to collect coverage data.

As soon as processing is complete, the results will be automatically displayed below your project on the Home page.

Desktop makes the process of collecting code coverage simple, and then gives you access to dynamic and powerful views of coverage trends.

If you still need technical assistance, we can help:

Submit A Support Ticket