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 few more steps than testListener option.

Prerequisites

Microsoft run-time components

...

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 --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

...

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:

...

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 environments depending on your contextenvironment variables required by the agent to attach to your application as a Profiler

Code Block
languagepowershell
$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="SL_CovCollectorAgent"
#SL_LogDir="C:\Sealights\logs"
#SL_LogLevel="6"

...