Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Prerequisites

Microsoft run-time components

Install Microsoft Visual C++ Redistributable for Visual Studio 2017 from: https://www.visualstudio.com/downloads/

...

Code Block
languagepowershell
iwr -OutFile vc_redist.x86.exe -UseBasicParsing -Uri https://go.microsoft.com/fwlink/?LinkId=746571 
Start-Process -FilePath vc_redist.x86.exe -ArgumentList "/Q" -Wait
iwr -OutFile vc_redist.x64.exe -UseBasicParsing -Uri https://go.microsoft.com/fwlink/?LinkId=746572 
Start-Process -FilePath vc_redist.x64.exe -ArgumentList "/Q" -Wait

Agent Token and Proxy settings

If needed, configure the coverage collector service by editing the SL.DotNet.CoverageCollectorService.exe.config file:

  • If you have not placed the sltoken.txt in the agents' folder, then in Sealights.Token put the token you've received from SeaLights

  • If a proxy is used, add a key named 'Sealights.Proxy' and set the value to a URL like "http://127.0.0.1:8888"

Coverage Collector Service Installation

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

    Code Block
    SL.DotNet.CoverageCollectorService.exe install start
  • Register our agent as a profiler in the services registry settings.

    1. Go to the registry under the following key: HK_LOCAL_MACHINE\System\CurrentControlSet\Services\{YourService}

    2. Add a Multi-String value called 'Environment' containing the following

      Code Block
      languagetext
      Cor_Profiler={01CA2C22-DC03-4FF5-8350-59E32A3536BA}
      Cor_Enable_Profiling=1
      COR_PROFILER_PATH_32=C:\Sealights\SL.DotNet\x86\SL.DotNet.ProfilerLib_x86.dll
      COR_PROFILER_PATH_64=C:\Sealights\SL.DotNet\x64\SL.DotNet.ProfilerLib_x64.dll
      SL_CollectorId=GlobalCollector
  • Restart your service manually via the Service Manager console or the following PowerShell command

    Code Block
    languagepowershell
    Restart-Service -Name {YourService} -Force

...

Note

The environment variables above added to the registry, must not contain quotes (") for the paths and have the paths updated to your local configuration (COR_PROFILER_PATH_32/64)

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

Info

See 'SeaLights .NET - command reference' for full parameter details

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.

Code Block
languagepowershell
SL.DotNet.exe startCollectorServiceSession --buildSessionIdFile buildSessionId.txt --labId my_labId --processName YourProcess.exe --includeChildProcesses true
Tip

At the successful completion of this step, you will see new entries appearing in the Cockpit > Live Agents Monitor: the CollectorServiceSession and a entity called Profiler with the version details of your service.

...

  • 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

Expand
titleTroubleshooting misconfiguration

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 https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer.
    You can refer to our dedicated article .NET - Deep Troubleshooting using Process Explorer for detailed instruction on how to use it with Sealights.

  3. You can enable advanced logs at the Profiler level according to the following instructions: https://sealights.atlassian.net/wiki/spaces/SUP/pages/1755480065/.NET+-+Collecting+Profiler+Logs#Collecting-Profiler-logs-from-Windows-Services

Running your tests

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

Info

See 'SeaLights .NET agent - Running tests' for details of how to run tests

Stopping coverage collection session

Code Block
languagepowershell
SL.DotNet.exe stopCollectorServiceSession --buildSessionIdFile buildSessionId.txt --processName YourProcess.exe

...