Here’s my setup
- SonarQube Community Edition v10.7 (96327) deployed on docker
- The source code is a solucion with 2 projects
1-Main project in VB called CalculatorApp
2-Test project in C# with one test
The code executed to get a new analysis is the following
dotnet sonarscanner begin /k:"CalculatorApp" /d:sonar.host.url="http://localhost:9000" /d:sonar.token="sqp_2e8d3f1b69aaed63255677bcee08f66" /d:sonar.vbnet.opencover.reportsPaths=coverage.xml /d:sonar.verbose=true
dotnet build --no-incremental
coverlet .\CalculatorTests\bin\Debug\net8.0\CalculatorTests.dll --target "dotnet" --targetargs "test --no-build" -f=opencover -o="coverage.xml"
dotnet sonarscanner end /d:sonar.token="sqp_2e8d3f1b69aaed63255677bcee08f66"
Running the previous commands I get the output attached in analysis1.log and coverage1.xml
The coverage is as show the following pictures
analysis1.log (142.4 KB)
coverage1xml.txt (14.9 KB)
If I change the coverlet command in order to only consider the namespace “CalculatorCore”
coverlet .\CalculatorTests\bin\Debug\net8.0\CalculatorTests.dll --target "dotnet" --targetargs "test --no-build" -f=opencover -o="coverage.xml" --include "[*]CalculatorCore.*"
I get a 100% coverage.by coverlet but sonarqube shows 0%.
analysis2.log (127.7 KB)
coverage2xml.txt (636 Bytes)
If whe compare coverage1xml.txt and coverage2xml.txt are very different, the first one has a lot of detail, the second one has a few lines.
My questions in this post is why sonarqube doesn’t show a 100% test coverage as coverlet result shows.
If you need more information about my scenario feel free to ask it me.
Thanks in advanced!