Hello
I develop library in c# 4.7.2
I develop libray of unit tests using xunit 2.9.0
In my pipeline I have a step to run sonar
All working fine, but when I look at the codecoverage, the value is 0%
I don’t understand why
The environment is
- SonarQube server 9.9.1.69595
- SonarScanner 4.8.0.2856
- SonarScanner for MSBuild 5.11
- jdk-19.0.1
- Windows Server 2019
- Project c# 4.7.2
- xunit 2.9.0
- Pipeline jenkins with jenkinsfile
- dotnet-coverage collect
The goal of the library is transformed an xml received in input and generated a new xml file in output
Then the unit test used InlineData with xml input and xml output, and compare the xml generated with the xml declared as InlineData
The tests are running successfully, but the code coverage is not computed
I don’t know what is missing
The jenkins file contains a step
withSonarQubeEnv(‘Myenv-SonarQube’) {
bat label: ‘Starting Sonar analysis’, script: ‘dotnet ’ + sqScannerMsBuildHome + ’ begin /k:’ + MY_PROJECT_NAME + ’ /n:’ + MY_PROJECT_NAME + ’ ’ + ‘/d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.qualitygate.wait=true ’ + ’ /v:’ + env.GitVersion_NuGetVersion + ‘_(#’ + env.BUILD_NUMBER + ‘)’ + ’ /d:sonar.dotnet.excludeTestProjects=true ’
bat label: ‘Building application with dotnet’, script: ‘“C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe” /t:restore,build MyPlugInTest\MyPlugInTest.csproj /p:Configuration=Debug /p:OutputPath=Publish\MySuffix’ + env.GitVersion_NuGetVersion + ’ /p:TargetFrameworkVersion=v4.7.2’
bat label: ‘Testing and coverage’, script: ‘dotnet-coverage collect "dotnet test “’ + projectDll + ‘” --filter DisplayName=MyPlugInTest.MyClassTest.Should_Succeed " -f xml -o “coverage.xml”’
bat label: ‘Ending Sonar analysis’, script: 'dotnet ’ + sqScannerMsBuildHome + ’ end ’
}
Thanks for your help and suggestion