-
-
Notifications
You must be signed in to change notification settings - Fork 285
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
Wrong coverage report with DynamicCodeCoverage xml file #467
Comments
Thanks for the detailed description and the sample project. I found the root cause for this issue: <range source_id="0" covered="no" start_line="19" start_column="17" end_line="19" end_column="18" />
<range source_id="0" covered="no" start_line="20" start_column="21" end_line="20" end_column="51" />
<range source_id="0" covered="no" start_line="21" start_column="17" end_line="21" end_column="18" /> Those elements indicate that the lines 19-21 are not covered ( The first <range source_id="0" covered="yes" start_line="14" start_column="13" end_line="23" end_column="16" /> This indicates, that the lines 14-23 are covered. ReportGenerator merges all the For me the XML file generated by dotnet-coverage seems to be incorrect. I'm not able to fix the issue within ReportGenerator. |
HI @danielpalme , thank you for the quick reply. My understanding of the range <range source_id="0" covered="yes" start_line="14" start_column="13" end_line="23" end_column="16" /> would be that this is the call of the Task.Run method. This method is called and therefore covered. And the fact that these lines are also including an anonymous method that then includes some not covered lines is stated in the xml file as well. I think this boils down to the question of how the semantics of a range is defined. On a related matter: A similar issue occurs when changing the output format to cobertura with the collect-coverage:
Produces the following xml: <?xml version="1.0" encoding="utf-8" standalone="yes"?>
<coverage line-rate="0.8235294117647058" branch-rate="0.5" complexity="3" version="1.9" timestamp="1638530614" lines-covered="14" lines-valid="17" branches-covered="1" branches-valid="2">
<sources />
<packages>
<package line-rate="0.8235294117647058" branch-rate="0" complexity="3" name="AsyncCoverage">
<classes>
<class line-rate="1" branch-rate="1" complexity="1" name="AsyncCoverage.Program" filename="C:\source\coverageSamples\AsyncCoverage\Program.cs">
<methods>
<method line-rate="1" branch-rate="1" complexity="1" name="Main" signature="(string[])">
<lines>
<line number="10" hits="1" branch="False" />
<line number="11" hits="1" branch="False" />
<line number="12" hits="1" branch="False" />
<line number="13" hits="1" branch="False" />
<line number="14" hits="1" branch="False" />
<line number="24" hits="1" branch="False" />
<line number="25" hits="1" branch="False" />
</lines>
</method>
</methods>
<lines>
<line number="10" hits="1" branch="False" />
<line number="11" hits="1" branch="False" />
<line number="12" hits="1" branch="False" />
<line number="13" hits="1" branch="False" />
<line number="14" hits="1" branch="False" />
<line number="24" hits="1" branch="False" />
<line number="25" hits="1" branch="False" />
</lines>
</class>
<class line-rate="0.7" branch-rate="0.5" complexity="2" name="AsyncCoverage.Program.<>c__DisplayClass0_0" filename="C:\source\coverageSamples\AsyncCoverage\Program.cs">
<methods>
<method line-rate="0.7" branch-rate="0.5" complexity="2" name="<Main>b__0" signature="()">
<lines>
<line number="14" hits="1" branch="False" />
<line number="15" hits="1" branch="True" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%" />
</conditions>
</line>
<line number="16" hits="1" branch="False" />
<line number="17" hits="1" branch="False" />
<line number="18" hits="1" branch="False" />
<line number="19" hits="0" branch="False" />
<line number="20" hits="0" branch="False" />
<line number="21" hits="0" branch="False" />
<line number="22" hits="1" branch="False" />
<line number="23" hits="1" branch="False" />
</lines>
</method>
</methods>
<lines>
<line number="14" hits="1" branch="False" />
<line number="15" hits="1" branch="True" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%" />
</conditions>
</line>
<line number="16" hits="1" branch="False" />
<line number="17" hits="1" branch="False" />
<line number="18" hits="1" branch="False" />
<line number="19" hits="0" branch="False" />
<line number="20" hits="0" branch="False" />
<line number="21" hits="0" branch="False" />
<line number="22" hits="1" branch="False" />
<line number="23" hits="1" branch="False" />
</lines>
</class>
</classes>
</package>
</packages>
</coverage> but the parser seems to be ignoring the anonymous method completely. |
First: I don't have an official description of the format. Especially the Coberatura format is quite difficult, since many tools produce output in Cobertura format. Any every tool does it in a slightly different way. Same is true for anonymous method in your latest Cobertura file. Regarding the DynamicCode format: |
If you have an idea how to handle the problem with the DynamicCode format, let me know. |
allow for custom fcc build of 4.7.1 so as to support async for ms code coverage
Used reportgenerator version: 5.0.0
Take the following c# application and compile it.
Collect coverage using the global dotnet-coverage tool.
Generate the report
Result is a report with 100% coverage although the resulting xml clearly shows partial coverage only.
Additional info:
Generating a cobuerta file with coverlet is reporting the expected results.
(The .dl is not a typo, somehow this is a way to make coverlet report correctly without the need of unit tests)
I have attached the c# project with the coverage reports (xml, cobertura and json)
AsyncCoverage.zip
The text was updated successfully, but these errors were encountered: