-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix coverage aggregation from multiple reports #8696
Comments
Seems I am having this issues too - with dotcover, when importing with net6.0 and net8.0 coverage goes to zero. |
The code coverage parsers and importers and aggregators are in https://github.com/SonarSource/sonar-dotnet/tree/master/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests Looking at https://sonarcloud.io/code?id=sonaranalyzer-dotnet&selected=sonaranalyzer-dotnet%3Aanalyzers%2Ftests%2FSonarAnalyzer.TestFramework%2FVerification%2FIssueValidation%2FIssueLocationPair.cs&line=68 at this moment in time, it appears to be fixed... |
#9018 could have improved coverage results. |
I would say "It hid the problem again" |
The problem is not with the aggregation but with AltCover reporting differently for different framework versions: This issue is blocked until AltCover's behavior is changed (which might not happen; I'm not sure it's a bug) or we find a better way to match |
We still know that there are only 2 in any case. And we report 3, so we should be able to improve the behavior. Same branchpoint issue might be relevant for any coverage tool |
@pavel-mikula-sonarsource, can you clarify how we would know that there are only two branch points? |
One thing we could do (and this might be what @pavel-mikula-sonarsource is proposing) is to look at the number of distinct branch points we find per report instead of in total. So we count the number of branches per report and then take the maximum of these counts as the number for all branches. |
Description
On sonar-dotnet build itself, we produce several coverage reports at the moment, each from a dedicated test project (here are the relevant fragments):
These gets all imported into coverage sensor and processed via our aggregation logic. For the production code in
SonarAnalyzer.TestFrameworkVerificationIssueValidationIssueLocationPair.cs
and line 68this produces 2 out of 3 covered conditions that don't make sense.
We need to fix the aggregation.
Situation
The affected production code is part of our test framework. It is tested:
coverage.DotNetCoverageTestFramework.xml.txt
coverage.DotNetCoverageNet7.net7.0-windows.xml.txt
andcoverage.DotNetCoverageNet48.net48.xml.txt
coverage.DotNetCoverageNet8.xml.txt
, because it doesn't reach this error state in the current set of testsCoverage data
Coverage data contains expected values like this:
coverage.DotNetCoverageTestFramework.xml.txt
Indicates that there are 2 branches and both are visited
coverage.DotNetCoverageNet7.net7.0-windows.xml.txt and it's net48 counterpart
Indicates that there are 2 branches, and one of them is visited - this is expected.
coverage.DotNetCoverageNet8.xml.txt
Indicates that there are 2 branches and none of them is visited from this test run - this is also expected
The text was updated successfully, but these errors were encountered: