Using GitLab for code storing and CI for Sonar analyzing. Spent great amount of time trying to import code coverage results from dotnet tests but still without success. Pipeline is running on Windows node to get the Code Coverage results. Sonar version is 8.6.
Getting this eror:
INFO: Parsing the XUnit Test Results file 'C:\GitLab-Runner\builds\Jtky_u8Y\0\auction\campaignservice\.\TestResults\UA-JENKINS-S$_UA-JENKINS-S_2021-09-21_17_23_37.trx'.
That’s the way I’m running tests and analyzing:
stages:
- build
build:
stage: build
variables:
GIT_STRATEGY: clone
JoobleListPath: C:\JoobleListPath
tags:
- windows
only:
- merge_requests
script:
- dotnet sonarscanner begin /k:"***" /d:sonar.host.url=*** /d:sonar.login="***" /d:sonar.cs.xunit.reportsPaths="TestResults/*.trx"
- dotnet build /nodereuse:false -c Release CampaignService.Api/campaign-service.csproj
- dotnet test -c Release --results-directory:"TestResults" --collect:"Code Coverage" --logger trx CampaignService.Domain.Tests/CampaignService.Domain.Tests.csproj
- dotnet test -c Release --results-directory:"TestResults" --collect:"Code Coverage" --logger trx CampaignService.Domain.Segmentation.Tests/CampaignService.Domain.Segmentation.Tests.csproj
- ./convert-test-results.ps1
- dotnet sonarscanner end /d:sonar.login="***"
Here is convert-test-results file:
Get-ChildItem -Recurse -Filter "*.coverage" | Foreach-Object {
$outfile = "$([System.IO.Path]::GetFileNameWithoutExtension($_.FullName)).coveragexml"
$output = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($_.FullName), $outfile)
& CodeCoverage\CodeCoverage.exe analyze /output:$output $_.FullName
}
Get-ChildItem -Recurse -Filter "*.coveragexml" | Foreach-Object {
$file = Join-Path -Path $_.Directory -ChildPath $_.Name
Copy-Item $file -Destination 'TestsResults'
}
What am I doing wrong?