Setting up a windows service

Coverage Collector Service Installation

As an Administrator, install and start the coverage collector service:

SL.DotNet.CoverageCollectorService.exe install --start

Register our agent as a profiler in the services registry settings:

SL.DotNet.exe instrumentService --serviceName {YourService} --force

Restart your service manually via the Service Manager console or the following PowerShell command

Restart-Service -Name {YourService} -Force
circle-check

Capturing coverage

During the time you want to run your tests and capture coverage, you can now start and stop the coverage collection of the SeaLights agent test listener

Starting coverage collection session

Before you start running your tests, you need to update the SeaLights test listener to start collecting coverage. You do so with the startCollectorServiceSession parameter.

SL.DotNet.exe startCollectorServiceSession --buildSessionIdFile buildSessionId.txt --labId my_labId --processName YourProcess.exe --includeChildProcesses true
circle-check
  • Note that this can be run on a remote machine (like the CI running the tests) while providing the host to start the session on using the parameter: --machine <host>

  • If you’re running several services on the machine, you can use the above command with --processName * and every service having the Sealights' environment variables defined in its Registry entry will be metered

circle-info

See Command Reference for full parameter details

chevron-rightTroubleshooting misconfigurationhashtag

If the Profiler doesn't start correctly, you can validate your configuration using the following approaches:

  1. Open the Event Viewer and search for possible errors under Local> Windows Log > Application

  2. Validate the correct variables were attached to the process of your service using a tool like Process Explorer - Sysinternalsarrow-up-right. You can refer to our dedicated article Deep Troubleshooting using Process Explorer for detailed instructions on how to use it with Sealights.

  3. You can enable advanced logs at the Profiler level according to the following instructions: Collecting Profiler logs from Windows Services

Running your tests

Now you can run any one of your tests that runs against this service and capture coverage.

circle-info

See Running tests for details of how to run tests

Stopping coverage collection session

Uninstalling Profiler from your Service

If needed, you can un-register the SeaLights profiler from your Service

Sample script

Last updated

Was this helpful?