Skip to content
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

CodeCoverage reports lines out of range for the test file #221

Open
milbrandt opened this issue Feb 9, 2021 · 4 comments
Open

CodeCoverage reports lines out of range for the test file #221

milbrandt opened this issue Feb 9, 2021 · 4 comments

Comments

@milbrandt
Copy link

FakeIt 2.0.5
Build Tools: MSBuild, VSTest, CodeCoverage

I tried to use FakeIt to creat a new unit test with a mock. Language standard is set to stdcpp17.

The file with the test using FakeIt has 104 lines (including commented lines). When I analysed CodeCoverage xml output file I fould several blocks referencing to the file. The first block seems to be ok, all start_lines are in the range of my test method.

But there are additional blocks with line numbers out of range for this file, e.g.

    <function id="1809028" name="LongLongSub" type_name="" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="5" lines_covered="0" lines_partially_covered="0" lines_not_covered="8">
  <ranges>
    <range source_id="52" covered="no" start_line="8204" start_column="0" end_line="8204" end_column="0" />
    <range source_id="52" covered="no" start_line="8206" start_column="0" end_line="8206" end_column="0" />
    <range source_id="52" covered="no" start_line="8215" start_column="0" end_line="8215" end_column="0" />
    <range source_id="52" covered="no" start_line="8219" start_column="0" end_line="8219" end_column="0" />
    <range source_id="52" covered="no" start_line="8221" start_column="0" end_line="8221" end_column="0" />
    <range source_id="52" covered="no" start_line="8224" start_column="0" end_line="8224" end_column="0" />
    <range source_id="52" covered="no" start_line="8227" start_column="0" end_line="8227" end_column="0" />
    <range source_id="52" covered="no" start_line="8228" start_column="0" end_line="8228" end_column="0" />
  </ranges>
</function>

<function id="308992" name="~MethodMockingContextBase&lt;short,unsigned short,short,short,short,iodbpsd *&gt;()" namespace="fakeit" type_name="MockImpl&lt;AbstractDllFanuc&gt;::MethodMockingContextBase&lt;short,unsigned short,short,short,short,iodbpsd *&gt;" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="1" lines_covered="0" lines_partially_covered="0" lines_not_covered="1">
  <ranges>
    <range source_id="52" covered="no" start_line="105" start_column="0" end_line="105" end_column="0" />
  </ranges>
</function>
<function id="309008" name="~MethodMockingContextBase&lt;short,unsigned short,short,short,unsigned short,unsigned short,unsigned short,iodbpmc *&gt;()" namespace="fakeit" type_name="MockImpl&lt;AbstractDllFanuc&gt;::MethodMockingContextBase&lt;short,unsigned short,short,short,unsigned short,unsigned short,unsigned short,iodbpmc *&gt;" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="1" lines_covered="0" lines_partially_covered="0" lines_not_covered="1">
  <ranges>
    <range source_id="52" covered="no" start_line="105" start_column="0" end_line="105" end_column="0" />
  </ranges>
</function>

These lines out of range caused crashes in the subsequent processing of the xml file in my tool chain.

@FranckRJ
Copy link
Collaborator

Why do you run the coverage on your tests files ?

@milbrandt
Copy link
Author

I want to import the code coverage from Visual Studio to SonarQube/SonarCloud. And there only the xml format is supported.
see at sonar.cfamily.vscoveragexml.reportsPath: Note that the .coveragexml report format offered by Visual Studio is not supported.

@FranckRJ
Copy link
Collaborator

You should exclude your tests from the code coverage, there is not point of analyzing them : https://docs.microsoft.com/en-us/visualstudio/test/customizing-code-coverage-analysis?view=vs-2019#include-or-exclude-assemblies-and-members

@milbrandt
Copy link
Author

The filter of test projects is done on SonarQube side. So it was possible to run the complete CI pipeline without the neeed of a runsettings file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants