Setup for .net core - xunit - bitbucket pipelines

Here is my setup:

  • .Net Core solution with a testing project using xunit
  • Bitbucket repository
    Script snippet:
  • export PATH="$PATH:/root/.dotnet/tools"
    - dotnet tool install -g dotnet-sonarscanner
    - >-
    dotnet sonarscanner begin /k:“XXX” /o:“XXX” /d:“sonar.login=XXX” /d:“”
    /d:“sonar.exclusions=/*.sql,/*.html” /d:“sonar.cs.xunit.reportsPaths=./CoreAPITest/TestResults/XUnitResults.xml” /d:“sonar.verbose=true”
    - dotnet build XXXAPI.sln
    - cd APITest
    - dotnet test --logger “trx;LogFileName=XUnitResults.xml” --verbosity detailed
    - cd …
    - dotnet sonarscanner end /d:“sonar.login=XXX”

Question: The process runs and reports to sonarcloud but doesn’t include code coverage. How do I get code coverage from the output of xunit testing?
I see in the end log 13:42:54.807 INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml

13:42:54.808 INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer but I am using .net and set the sonar.cs.xunit.reportsPaths property. What am I missing here?

Hi @jabbott and welcome to the community !

We support only the test results / number of tests with the XUnit format, not the coverage. Do you see at least these results ?

For supported format for both, please have a look at the documentation :