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

Branch coverage is reported wrongly #105

Closed
theold190 opened this Issue Jun 26, 2015 · 3 comments

Comments

Projects
None yet
4 participants
@theold190

theold190 commented Jun 26, 2015

In some cases you might have 0 branches in all files. In that case branch coverage is reported differently in a HTML report:

  • per file it is reported as 100%, 0/0
  • per module it is reported as exec:0, total:0, coverage: 0%

It looks like 0% value is selected to avoid the zero division. An extra check could be added to show a proper statistics information.

Tested with official gcovr 3.2 release.

@davis-tim

This comment has been minimized.

davis-tim commented Dec 14, 2015

I can confirm the different behaviour.

The calculation for the branch coverage for the coverage report is:

    branches_covered = 100.0 if class_branches == 0 else 100.0*class_branch_hits/class_branches

But for the module the coverage is calculated as follows:

    coverage = 0.0 if branchTotal == 0 else round(100.0*branchCovered / branchTotal,1)
@mayeut

This comment has been minimized.

Contributor

mayeut commented Jan 15, 2018

Also related, #149

A unique behavior shall be chosen for this case. I'd like to see something other than choosing between 0 % and 100 % if possible (PR ready if you're interested):
A light gray background and - % string

e.g.
capture d ecran 2018-01-15 a 20 33 34

@latk

This comment has been minimized.

Member

latk commented Jan 15, 2018

@mayeut That looks like a reasonable approach to visualize this case. If you already have a PR ready do submit it please. I would have otherwise deferred this issue until after some improvements from the dev branch have been backported (refactoring into multiple files, and template-based HTML reports).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment