Can't import my xUnit tests' results to Sonar

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:

  - build

  stage: build
    GIT_STRATEGY: clone
    JoobleListPath: C:\JoobleListPath
    - windows
    - merge_requests
    - dotnet sonarscanner begin /k:"***" /*** /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?


Welcome to the community!

First, your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

8.6 → 8.9.2 → 9.1 (last step optional)

Regarding your actual question, what you’ve listed as an error is only an informational log message telling you your test report is being parsed. Is there a line after this in the analysis log that contains ERROR?