Versions Compared

Key

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

...

The Background Listener option allows you to capture coverage from any application without changing the command you use to run it but requires more steps than testListener option.

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"

Running the process with the SeaLights .NET agent using the testListener option

To capture coverage from a single application, you can run it with the SeaLights .NET agent, which will capture coverage from it when it runs, and tests are run against it.

Code Block
languagepowershell
SL.DotNet.exe testListener --buildSessionIdFile buildSessionId.txt --labId my_labId --target c:\MyApplication\App.exe --workingDir c:\WorkingDir --targetArgs "-Flag1 true MyTest.dll"

The sample command above is replacing the regular command used to startup the application captured: c:\MyApplication\App.exe -Flag1 true MyTest.dll executed from the c:\WorkingDir directory

Tip

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

Info

See SeaLights .NET - Command reference: Starting the Test Listener for full parameters details . 

Running the SeaLights .NET agent as a background listener

To capture coverage from any application without changing the command you run, you can execute the SeaLights .NET agent as a background process, which will capture coverage from any process with the SeaLights .NET agent attached as a profiler.

The expected steps are then:

  1. Start the Sealights .NET background listener

  2. Set up the environment variable to enable the Sealights .NET Profiler

  3. Start your application

Starting the SeaLights .NET agent background listener

To run the background process, you use the startBackgroundTestListener flag and provide a unique session key:

Code Block
languagepowershell
SL.DotNet.exe startBackgroundTestListener --buildSessionIdFile buildSessionId.txt --labId my_labId --testListenerSessionKey SL_CovCollectorAgent

Setting the SeaLights .NET agent as a profiler

Now, you need to run (all) your processes - i.e., including your application - with the SeaLights .NET agent defined as a profiler before starting your application.
This is done by setting the following environment variables in the shell used to run your process:

  • Cor_Profiler set to {01CA2C22-DC03-4FF5-8350-59E32A3536BA}

  • Cor_Enable_Profiling set to 1

  • Cor_Profiler_Path_32 set to the path of SL.DotNet.ProfilerLib_x86.dll

  • Cor_Profiler_Path_64 set to the path of SL.DotNet.ProfilerLib_x64.dll

  • SL_CollectorId set to the same session key provided to the startBackgroundTestListener command

Note

You should unset the environment variables before running any process that you do not want to capture coverage from

Setting the environment variables for the Profiler agent

You can use the following PowerShell commands to declare the environment variables required by the agent to attach to your application as a Profiler

...

Tip

At the successful completion of this step, after starting your application with its regular command, you will see new entries appearing in the Cockpit > Live Agents Monitor: the testListener and a entity called Profiler with the version details of your application.

Stopping the SeaLights .NET agent background listener

Once you have finished collecting coverage from the process, you need to stop the background listener. This is done by using the stopBackgroundTestListener flag with the session key previously used

Code Block
languagepowershell
SL.DotNet.exe stopBackgroundTestListener --buildSessionIdFile buildSessionId.txt --testListenerSessionKey SL_CovCollectorAgent
Info

See 'SeaLights .NET - command reference' for full parameter details of all the commands listed above.

...