-
Notifications
You must be signed in to change notification settings - Fork 11
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
[cobertura] Missing branch coverage when all branches are covered #104
Comments
It is also worth to mention that in the same report other lines are correctly marked, e.g.: <line number="84" hits="1" branch="True" condition-coverage="100% (2/2)">
<conditions>
<condition number="0" type="jump" coverage="100%" />
</conditions>
</line> |
@viceice could you please upgrade all your test projects to use latest |
@jakubch1 I'm using the latest non-preview (17.9.0) of I'm using lockfiles and central versioning, so versions are verified. Should i try the latest preview?
I'm using a <?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<RunConfiguration>
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0">
<Configuration>
<Format>Cobertura</Format>
<CodeCoverage>
<ModulePaths>
<!-- Disable native instrumentation, causes SharePoint debug issues -->
<EnableStaticNativeInstrumentation>False</EnableStaticNativeInstrumentation>
<EnableDynamicNativeInstrumentation>False</EnableDynamicNativeInstrumentation>
<Include>
<ModulePath>Proj(\.[.a-zA-Z]+)?\.dll$</ModulePath>
</Include>
<Exclude>
<ModulePath>Proj(\..+)?\.Test\.dll$</ModulePath>
</Exclude>
</ModulePaths>
<Attributes>
<Exclude>
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
</Exclude>
</Attributes>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<NUnit>
<TestOutputXml>nunit</TestOutputXml>
<OutputXmlFolderMode>RelativeToResultDirectory</OutputXmlFolderMode>
<NewOutputXmlFileForEachRun>true</NewOutputXmlFileForEachRun>
</NUnit>
</RunSettings> which is referenced in repo root <RunSettingsFilePath>$(MSBuildThisFileDirectory)/proj.runsettings</RunSettingsFilePath> |
@viceice thanks for info. How you execute tests? |
I'm running two comands on CI. First running cheap tests in dotnet test test --no-build
...
Passed! - Failed: 0, Passed: 680, Skipped: 14, Total: 694, Duration: 17 s - Proj.Test.dll (net8.0)
Attachments:
~\proj\test\Proj.XY.Test\TestResults\c64ddcc7-72a7-45a8-aae4-32e5cafbb395\user_PCNAME_2024-02-29.08_36_39.cobertura.xml This gives the first coverage file. The second command runs on a native SharePoint server for CI (jenkins node) purposes. dotnet test sp/test --no-build
...
Passed! - Failed: 0, Passed: 680, Skipped: 14, Total: 694, Duration: 17 s - Proj.SP.Test.dll (net48)
Attachments:
~\proj\sp\test\Proj.SP.Test\TestResults\5f49f3d0-341e-4fe5-83ac-e6e2bd5f991e\user_PCNAME_2024-02-29.08_37_31.cobertura.xml |
@viceice thanks for info. What version of .NET SDK you use? @fhnaseer I suspect that that |
my local system
Can't check CI right now, but can reproduce locally with above versions. I've also Visual Studio 17.9.1 on my local machine and the corresponding build tools on CI. |
@viceice thanks for reporting this. We will work on fixing it when using dotnet test. As workaround you could try to switch to use
You would need also to remove runsettings file from csproj and convert it to coverage.config (main tag should be |
my current workaround is to use |
is there any other benefit to use |
By using Build-in tool is running coverage for each test project separately and then merges results. While dotnet-coverage is using 1 collection for all test projects and merging is not needed. It means that if same project is referenced in many test projects build-in needs to instrument it several times. External tool instruments just once. Also external tool targets |
ok, will give it a try when our infra is back running 🙈 neverless this bug should be fixed anyways 🙃 |
OK, dotnet-coverage works partly better. I now have totally missing lines in one report. #if NETFRAMEWORK
// some full framework code
#else
// some dotnet core code
#endif So the lines for the non-full framework are missing in the sp report. |
@viceice Can you please tell version of |
it's 17.10.3 |
I am looking at the Jenkins ticket. With the latest |
it's same as already mentioned above. I'm using central versioning and lockfiles. I also verified before. |
@viceice Can you please run test on individual test projects (rather on solution level) and share coverage files generated per test project? |
I can only provide parts of it. hopefully tomorrow. I think the lines already mentioned are the interesting ones. |
@viceice we believe what is happening is your case:
To make sure that this is your scenario we need to get information about line 61 for all projects from point 1 (separately) and if this is the scenario we will not be able to fix it. The only way is to use |
Report a <lines>
<line number="15" hits="1" branch="False" />
<line number="21" hits="1" branch="False" />
<line number="23" hits="0" branch="False" />
<line number="25" hits="0" branch="False" />
<line number="26" hits="1" branch="False" />
<line number="28" hits="1" branch="False" />
<line number="29" hits="1" branch="False" />
<line number="30" hits="1" branch="False" />
<line number="31" hits="1" branch="False" />
<line number="32" hits="1" branch="False" />
<line number="33" hits="1" branch="False" />
<line number="34" hits="1" branch="False" />
<line number="37" hits="1" branch="False" />
<line number="38" hits="1" branch="True" />
<line number="39" hits="0" branch="False" />
<line number="40" hits="0" branch="False" />
<line number="41" hits="0" branch="False" />
<line number="44" hits="1" branch="False" />
<line number="45" hits="1" branch="True" condition-coverage="100% (4/4)">
<conditions>
<condition number="0" type="jump" coverage="100%" />
<condition number="1" type="jump" coverage="100%" />
</conditions>
</line>
<line number="46" hits="1" branch="False" />
<line number="47" hits="1" branch="False" />
<line number="48" hits="1" branch="False" />
<line number="50" hits="1" branch="True" condition-coverage="100% (2/2)">
<conditions>
<condition number="0" type="jump" coverage="100%" />
</conditions>
</line>
<line number="51" hits="1" branch="False" />
<line number="52" hits="1" branch="False" />
<line number="54" hits="1" branch="False" />
<line number="55" hits="1" branch="True" />
<line number="56" hits="1" branch="False" />
<line number="58" hits="0" branch="False" />
<line number="59" hits="0" branch="False" />
<line number="61" hits="1" branch="True" />
<line number="62" hits="1" branch="False" />
<line number="63" hits="1" branch="False" />
<line number="64" hits="1" branch="False" />
<line number="67" hits="0" branch="False" />
<line number="68" hits="0" branch="False" />
<line number="69" hits="1" branch="False" />
<line number="71" hits="1" branch="False" />
<line number="73" hits="1" branch="False" />
</lines> Report b <lines>
<line number="15" hits="0" branch="False" />
<line number="21" hits="0" branch="False" />
<line number="23" hits="0" branch="False" />
<line number="25" hits="0" branch="False" />
<line number="26" hits="0" branch="False" />
<line number="28" hits="0" branch="False" />
<line number="29" hits="0" branch="False" />
<line number="30" hits="0" branch="False" />
<line number="31" hits="0" branch="False" />
<line number="32" hits="0" branch="False" />
<line number="33" hits="0" branch="False" />
<line number="34" hits="0" branch="False" />
<line number="37" hits="0" branch="False" />
<line number="38" hits="0" branch="True" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
</conditions>
</line>
<line number="39" hits="0" branch="False" />
<line number="40" hits="0" branch="False" />
<line number="41" hits="0" branch="False" />
<line number="44" hits="0" branch="False" />
<line number="45" hits="0" branch="True" condition-coverage="0% (0/4)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
<condition number="1" type="jump" coverage="0%" />
</conditions>
</line>
<line number="46" hits="0" branch="False" />
<line number="47" hits="0" branch="False" />
<line number="48" hits="0" branch="False" />
<line number="50" hits="0" branch="True" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
</conditions>
</line>
<line number="51" hits="0" branch="False" />
<line number="52" hits="0" branch="False" />
<line number="54" hits="0" branch="False" />
<line number="55" hits="0" branch="True" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
</conditions>
</line>
<line number="56" hits="0" branch="False" />
<line number="58" hits="0" branch="False" />
<line number="59" hits="0" branch="False" />
<line number="61" hits="0" branch="True" condition-coverage="0% (0/4)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
<condition number="1" type="jump" coverage="0%" />
</conditions>
</line>
<line number="62" hits="0" branch="False" />
<line number="63" hits="0" branch="False" />
<line number="64" hits="0" branch="False" />
<line number="67" hits="0" branch="False" />
<line number="68" hits="0" branch="False" />
<line number="69" hits="0" branch="False" />
<line number="71" hits="0" branch="False" />
<line number="73" hits="0" branch="False" />
</lines> Report c <lines>
<line number="15" hits="0" branch="False" />
<line number="21" hits="0" branch="False" />
<line number="23" hits="0" branch="False" />
<line number="25" hits="0" branch="False" />
<line number="26" hits="0" branch="False" />
<line number="28" hits="0" branch="False" />
<line number="29" hits="0" branch="False" />
<line number="30" hits="0" branch="False" />
<line number="31" hits="0" branch="False" />
<line number="32" hits="0" branch="False" />
<line number="33" hits="0" branch="False" />
<line number="34" hits="0" branch="False" />
<line number="37" hits="0" branch="False" />
<line number="38" hits="0" branch="True" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
</conditions>
</line>
<line number="39" hits="0" branch="False" />
<line number="40" hits="0" branch="False" />
<line number="41" hits="0" branch="False" />
<line number="44" hits="0" branch="False" />
<line number="45" hits="0" branch="True" condition-coverage="0% (0/4)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
<condition number="1" type="jump" coverage="0%" />
</conditions>
</line>
<line number="46" hits="0" branch="False" />
<line number="47" hits="0" branch="False" />
<line number="48" hits="0" branch="False" />
<line number="50" hits="0" branch="True" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
</conditions>
</line>
<line number="51" hits="0" branch="False" />
<line number="52" hits="0" branch="False" />
<line number="54" hits="0" branch="False" />
<line number="55" hits="0" branch="True" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
</conditions>
</line>
<line number="56" hits="0" branch="False" />
<line number="58" hits="0" branch="False" />
<line number="59" hits="0" branch="False" />
<line number="61" hits="0" branch="True" condition-coverage="0% (0/4)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
<condition number="1" type="jump" coverage="0%" />
</conditions>
</line>
<line number="62" hits="0" branch="False" />
<line number="63" hits="0" branch="False" />
<line number="64" hits="0" branch="False" />
<line number="67" hits="0" branch="False" />
<line number="68" hits="0" branch="False" />
<line number="69" hits="0" branch="False" />
<line number="71" hits="0" branch="False" />
<line number="73" hits="0" branch="False" />
</lines> Report d <lines>
<line number="15" hits="0" branch="False" />
<line number="21" hits="0" branch="False" />
<line number="23" hits="0" branch="False" />
<line number="25" hits="0" branch="False" />
<line number="26" hits="0" branch="False" />
<line number="28" hits="0" branch="False" />
<line number="29" hits="0" branch="False" />
<line number="30" hits="0" branch="False" />
<line number="31" hits="0" branch="False" />
<line number="32" hits="0" branch="False" />
<line number="33" hits="0" branch="False" />
<line number="34" hits="0" branch="False" />
<line number="37" hits="0" branch="False" />
<line number="38" hits="0" branch="True" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
</conditions>
</line>
<line number="39" hits="0" branch="False" />
<line number="40" hits="0" branch="False" />
<line number="41" hits="0" branch="False" />
<line number="44" hits="0" branch="False" />
<line number="45" hits="0" branch="True" condition-coverage="0% (0/4)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
<condition number="1" type="jump" coverage="0%" />
</conditions>
</line>
<line number="46" hits="0" branch="False" />
<line number="47" hits="0" branch="False" />
<line number="48" hits="0" branch="False" />
<line number="50" hits="0" branch="True" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
</conditions>
</line>
<line number="51" hits="0" branch="False" />
<line number="52" hits="0" branch="False" />
<line number="54" hits="0" branch="False" />
<line number="55" hits="0" branch="True" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
</conditions>
</line>
<line number="56" hits="0" branch="False" />
<line number="58" hits="0" branch="False" />
<line number="59" hits="0" branch="False" />
<line number="61" hits="0" branch="True" condition-coverage="0% (0/4)">
<conditions>
<condition number="0" type="jump" coverage="0%" />
<condition number="1" type="jump" coverage="0%" />
</conditions>
</line>
<line number="62" hits="0" branch="False" />
<line number="63" hits="0" branch="False" />
<line number="64" hits="0" branch="False" />
<line number="67" hits="0" branch="False" />
<line number="68" hits="0" branch="False" />
<line number="69" hits="0" branch="False" />
<line number="71" hits="0" branch="False" />
<line number="73" hits="0" branch="False" />
</lines> |
Only project a fully covers the line 61 (see code in issue description) |
Is project a single test project or solution? Could you please provide diagnostic logs from project a? https://github.com/microsoft/vstest/blob/main/docs/troubleshooting.md#collect-logs-and-crash-dump |
Yes, there are 4 test projects, but they depend on each other (tree)
|
You can skip dumps. Enough for us is: |
wait, that project build's for net8.0 and net48. so probably another coverage result merge happens? now running for both frameworks seperately. |
Project a with net8.0 <lines>
<line number="15" hits="1" branch="False" />
<line number="21" hits="1" branch="False" />
<line number="23" hits="0" branch="False" />
<line number="25" hits="0" branch="False" />
<line number="26" hits="1" branch="False" />
<line number="28" hits="1" branch="False" />
<line number="29" hits="1" branch="False" />
<line number="30" hits="1" branch="False" />
<line number="31" hits="1" branch="False" />
<line number="32" hits="1" branch="False" />
<line number="33" hits="1" branch="False" />
<line number="34" hits="1" branch="False" />
<line number="37" hits="1" branch="False" />
<line number="38" hits="1" branch="True" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%" />
</conditions>
</line>
<line number="39" hits="0" branch="False" />
<line number="40" hits="0" branch="False" />
<line number="41" hits="0" branch="False" />
<line number="44" hits="1" branch="False" />
<line number="45" hits="1" branch="True" condition-coverage="100% (4/4)">
<conditions>
<condition number="0" type="jump" coverage="100%" />
<condition number="1" type="jump" coverage="100%" />
</conditions>
</line>
<line number="46" hits="1" branch="False" />
<line number="47" hits="1" branch="False" />
<line number="48" hits="1" branch="False" />
<line number="50" hits="1" branch="True" condition-coverage="100% (2/2)">
<conditions>
<condition number="0" type="jump" coverage="100%" />
</conditions>
</line>
<line number="51" hits="1" branch="False" />
<line number="52" hits="1" branch="False" />
<line number="54" hits="1" branch="False" />
<line number="55" hits="1" branch="True" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%" />
</conditions>
</line>
<line number="56" hits="1" branch="False" />
<line number="58" hits="0" branch="False" />
<line number="59" hits="0" branch="False" />
<line number="61" hits="1" branch="True" condition-coverage="50% (2/4)">
<conditions>
<condition number="0" type="jump" coverage="50%" />
<condition number="1" type="jump" coverage="50%" />
</conditions>
</line>
<line number="62" hits="1" branch="False" />
<line number="63" hits="1" branch="False" />
<line number="64" hits="1" branch="False" />
<line number="67" hits="0" branch="False" />
<line number="68" hits="0" branch="False" />
<line number="69" hits="1" branch="False" />
<line number="71" hits="1" branch="False" />
<line number="73" hits="1" branch="False" />
</lines> Project a with net48 <lines>
<line number="15" hits="1" branch="False" />
<line number="21" hits="1" branch="False" />
<line number="23" hits="0" branch="False" />
<line number="25" hits="0" branch="False" />
<line number="26" hits="1" branch="False" />
<line number="28" hits="1" branch="False" />
<line number="29" hits="1" branch="False" />
<line number="30" hits="1" branch="False" />
<line number="31" hits="1" branch="False" />
<line number="32" hits="1" branch="False" />
<line number="33" hits="1" branch="False" />
<line number="34" hits="1" branch="False" />
<line number="37" hits="1" branch="False" />
<line number="38" hits="1" branch="True" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%" />
</conditions>
</line>
<line number="39" hits="0" branch="False" />
<line number="40" hits="0" branch="False" />
<line number="41" hits="0" branch="False" />
<line number="44" hits="1" branch="False" />
<line number="45" hits="1" branch="True" condition-coverage="100% (4/4)">
<conditions>
<condition number="0" type="jump" coverage="100%" />
<condition number="1" type="jump" coverage="100%" />
</conditions>
</line>
<line number="46" hits="1" branch="False" />
<line number="47" hits="1" branch="False" />
<line number="48" hits="1" branch="False" />
<line number="50" hits="1" branch="True" condition-coverage="100% (2/2)">
<conditions>
<condition number="0" type="jump" coverage="100%" />
</conditions>
</line>
<line number="51" hits="1" branch="False" />
<line number="52" hits="1" branch="False" />
<line number="54" hits="1" branch="False" />
<line number="55" hits="1" branch="True" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%" />
</conditions>
</line>
<line number="56" hits="1" branch="False" />
<line number="58" hits="0" branch="False" />
<line number="59" hits="0" branch="False" />
<line number="61" hits="1" branch="True" condition-coverage="50% (2/4)">
<conditions>
<condition number="0" type="jump" coverage="50%" />
<condition number="1" type="jump" coverage="50%" />
</conditions>
</line>
<line number="62" hits="1" branch="False" />
<line number="63" hits="1" branch="False" />
<line number="64" hits="1" branch="False" />
<line number="67" hits="0" branch="False" />
<line number="68" hits="0" branch="False" />
<line number="69" hits="1" branch="False" />
<line number="71" hits="1" branch="False" />
<line number="73" hits="1" branch="False" />
</lines> |
So it seems it's again the wrong merge when running both framework tests once 🤔 |
Unfortunately this can't be fixed because:
means line has 2 conditions and for each one case is covered. We are not able to calculate correct merge result (we don't know which part of condition was really covered) so we decide to remove conditions (similar to ReportGenerator). It is limitation of cobertura format. 50% + 50% could be merged to 50% or 100%. The only workaround is to use |
Thanks, i already use |
I understand that this is a limitation of the cobertura report format (or more precisely this is a problem of all reports, the actual coverage can only be computed with the execution data). Despite of this architectural problem I think it would be better if you change the output in such cases. Your current output is |
@viceice Just a heads up. Are you sure |
no, was a typo and already moved to correct place |
I have two test projects which are running on seperate ci nodes because of different requirements.
So i get two coverage files which i like to import in jenkins reports.
The code:
Project
a
, which fully covers that line gives:Project
b
doesn't cover that line (which is expected) and gives:Both reports should be identical beside coverage values.
The text was updated successfully, but these errors were encountered: