- ALM used: GitHub
- CI system used GitHub Actions
- Scanner command used when applicable:
- Languages of the repository: C# (.NET 10)
I use SonarCloud to scan all our PRs. This is triggered in GitHub Actions. This is essentially what is running:
dotnet restore
.sonar/scanner/dotnet-sonarscanner begin /k:"******" /o:"******" /d:sonar.token="***" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="coverage.xml"
dotnet-coverage collect "dotnet test --no-build --configuration Release" \
-f xml \
-o "coverage.xml"
.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="*********"
However, in the SonarQube Cloud web UI I get:
Coverage
There are not enough lines to compute coverage
In the PR integration in GitHub, I get 0% coverage. It is not triggering a fail for the 80% coverage for new code configuration I have in Sonar.
How can I debug this?
From the logs, I see that the coverage.xml is created correctly:
Code coverage results: coverage.xml.
I see a lot of this in the logs:
INFO: Indexing files...
INFO: Project configuration:
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.Tracing.UnitTests'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/test/**redacted**.Core.Tracing.UnitTests
INFO: Test paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Core...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.Auth0.UnitTests'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/test/**redacted**.Core.Auth0.UnitTests
INFO: Test paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Core...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.Logging.UnitTests'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/test/**redacted**.Core.Logging.UnitTests
INFO: Test paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Core...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.Observability'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/src/**redacted**.Core.Observability
INFO: Source paths: packages.lock.json, obj/**redacted**.Core.Observability.csproj.n...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.Logging'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/src/**redacted**.Core.Logging
INFO: Source paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Co...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.Tracing'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/src/**redacted**.Core.Tracing
INFO: Source paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Co...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.DynamoDb'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/src/**redacted**.Core.DynamoDb
INFO: Source paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Co...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.API.UnitTests'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/test/**redacted**.Core.API.UnitTests
INFO: Test paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Core...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.Metrics.UnitTests'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/test/**redacted**.Core.Metrics.UnitTests
INFO: Test paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Core...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.Auth0'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/src/**redacted**.Core.Auth0
INFO: Source paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Co...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.Metrics'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/src/**redacted**.Core.Metrics
INFO: Source paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Co...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.API'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/src/**redacted**.Core.API
INFO: Source paths: packages.lock.json, obj/**redacted**.Core.API.csproj.nuget.dgspe...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.Messaging.UnitTests'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/test/**redacted**.Core.Messaging.UnitTests
INFO: Test paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Core...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.TestHelpers.UnitTests'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/test/**redacted**.Core.TestHelpers.UnitTests
INFO: Test paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Core...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.UnitTests'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/test/**redacted**.Core.UnitTests
INFO: Test paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Core...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.Messaging'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/src/**redacted**.Core.Messaging
INFO: Source paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Co...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.Observability.UnitTests'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/test/**redacted**.Core.Observability.UnitTests
INFO: Test paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Core...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.DynamoDb.UnitTests'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/test/**redacted**.Core.DynamoDb.UnitTests
INFO: Test paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Core...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.TestHelpers'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/src/**redacted**.Core.TestHelpers
INFO: Test paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Core...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/src/**redacted**.Core
INFO: Source paths: packages.lock.json, obj/project.assets.json, obj/**redacted**.Co...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**.Core.FastEndpoints'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core/src/**redacted**.Core.FastEndpoints
INFO: Source paths: Binding/IHasProfileId.cs, Binding/ProfileIdBinder.cs, GlobalU...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: Indexing files of module '**redacted**-Guide_**redacted**.Core'
INFO: Base dir: /home/runner/work/**redacted**.Core/**redacted**.Core
INFO: Source paths: .github/labels.yml, .github/dependabot.yml, .github/workflows...
INFO: Excluded sources: coverage.xml, **/build-wrapper-dump.json
INFO: Excluded sources for coverage: **/LogAdapter.cs
INFO: 193 files indexed (done) | time=133ms
INFO: Quality profile for cs: Sonar way
INFO: Quality profile for json: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: Quality profile for yaml: Sonar way
Which I assume is positive.