My project is dot-net Core running in a unix docker environment. Using XUnit tests.
The Coverage report goes nicely into SonarQube, but the number of Executed Unit Tests is always a dash, or 0 on the dashboard.
Can anyone give me a hint as to what to try next? Below is the script I am running.
Start scanner
RUN dotnet sonarscanner begin
/k:“$SONAR_PROJECT”
/d:sonar.host.url=“$SONAR_HOST”
/d:sonar.token=“$SONAR_KEY”
/d:sonar.verbose=true
/d:sonar.coverageReportPaths=“coverage/SonarQube.xml”
/d:sonar.cs.xunit.reportsPaths=“TestResults/TestResult.xml”
/d:sonar.branch.name=“$SONAR_BRANCH_NAME”
/v:“1.1.28.0”
Perform Restore and Build
RUN dotnet restore “PimsAdapterService.sln”
RUN dotnet build --no-restore “PimsAdapterService.sln” -c Release
Run dotnet test setting the output on the /coverage folder
RUN dotnet test PimsAdapterXUnit/PimsAdapterXUnit.csproj --collect:“XPlat Code Coverage” --results-directory ./coverage
Create the code coverage file in sonarqube format using the cobertura file generated from the dotnet test command
RUN reportgenerator “-reports:./coverage/*/coverage.cobertura.xml” “-targetdir:coverage” “-reporttypes:SonarQube”
Run dotnet test again to generate the TestResult.xml file
RUN dotnet test PimsAdapterXUnit/PimsAdapterXUnit.csproj --logger “trx;logfilename=TestResult.xml”
Create the test execute result file to pass to sonarqube
RUN reportgenerator “-reports:/src/PimsAdapterXUnit/TestResults/TestResult.xml” “-targetdir:TestResults” “-reporttypes:SonarQube”
Stop scanner
RUN dotnet sonarscanner end /d:sonar.token=“$SONAR_KEY”