...
Code Block |
---|
|
SL.DotNet.CoverageCollectorService.exe install --start |
Register our agent as a profiler in the IIS services (two specific services - WAS and W3SVC):
...
Code Block |
---|
|
SL.DotNet.exe startCollectorServiceSession --buildSessionIdFile buildSessionId.txt --labId my_labId --processName w3wp.exe --processTagapplicationPool DefaultAppPool --includeChildProcesses true |
...
Now you can run any one of your tests that run against this IIS instance and capture coverage (Don’t forget to send a start and end command with the test stage name):
...
Note: This command can be run on a remote machine (like the CI running the tests) while providing the host to start the session on it, using the parameter: --machine <IIS host>
Un-installing the Coverage Collector Service
...
Code Block |
---|
|
SL.DotNet.CoverageCollectorService.exe uninstall |
...
Code Block |
---|
|
# ===== SECTION TO UPDATE ====
$SL_TOKEN="123456789" #Prefer an Env variable from your Credentials Manager
### Env specific
$SL_BSID_FILE="$SEALIGHTS_PATH\buildSessionId.txt"
$SL_ENV_LABID="TestLabEnv@Automation"
### IIS Service specific
$IIS_AppPool="DefaultAppPool"
# ============================
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$previousProgressPref=$global:ProgressPreference && $global:ProgressPreference = "SilentlyContinue" #Disable Progress bar topowershell to speed up download and expand archive command
### Install Agent and Token ###
iwr -OutFile sealights-dotnet-agent.zip -UseBasicParsing -Uri https://agents.sealights.co/dotnetcore/latest/sealights-dotnet-agent-windows-self-contained.zip
Expand-Archive .\sealights-dotnet-agent.zip -DestinationPath sl-dotnet-agent -Force
Write-Output "[Sealights] .NetCore Agent version is: $(Get-Content .\sl-dotnet-agent\version.txt)"
$global:ProgressPreference = $previousProgressPref #Restore progress bar
Out-File -Input-Object $SL_TOKEN -NoNewline -Force ".\sl-dotnet-agent\sltoken.txt"
### Install SL Collector Service ###
Invoke-Expression .\sl-dotnet-agent\SL.DotNet.CoverageCollectorService.exe install start
### Register SL service into IIS
Invoke-Expression .\sl-dotnet-agent\SL.DotNet.exe instrumentIIS --force
Invoke-Expression iisreset /restart
# Starting session for specific app version
Invoke-Expression .\sl-dotnet-agent\SL.DotNet.exe startCollectorServiceSession --buildSessionIdFile $SL_BSID_FILE --processName w3wp.exe --processTag $IIS_AppPool `
--includeChildProcesses true --logEnabled true --logAppendConsole true --labId $SL_ENV_LABID
#### You can start your tests #### |