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

Reporting incorrect coverage percentage from xml file #49

Open
valemany opened this issue Nov 21, 2017 · 5 comments
Open

Reporting incorrect coverage percentage from xml file #49

valemany opened this issue Nov 21, 2017 · 5 comments

Comments

@valemany
Copy link

Thanks in advance for looking into this.

I have atttached the xml file that the plugin is reading. In github it says that coverage is 48% but the actual coverage should be 41%.

coverturaXml.docx

@carlosmmelo
Copy link

here is the above file in a gist:
https://gist.github.com/carlosmmelo/459d1c9ae7df5d51bcbc6ac86d43dac3

@carlosmmelo
Copy link

carlosmmelo commented Nov 21, 2017

I'm having the same issue with jacoco

XML report lines covered is 8% and this plugin its publishing 45% which is wayyyyy too much of a difference.

I see that your math is good at:

however I suspect its an issue with the parser, it would be good to add at least a debug mode for more details to see if whats been stored into lineMissed and lineCovered its parsed correctly

@valemany
Copy link
Author

The covertura parser is doing the following calculation:

**return lineRate / 2 + branchRate / 2;**

The lineRate already gives you the % of lines covered, do not understand why branchRate matters in this case.

You can find this here:

https://github.com/jenkinsci/github-pr-coverage-status-plugin/blob/master/src/main/java/com/github/terma/jenkins/githubprcoveragestatus/CoberturaParser.java#L61

@prolificcoder
Copy link

prolificcoder commented Apr 26, 2018

Did you find a solution for your problem or a workaround? The plugin looks solid and it posting coverage data nicely but reporting wrong coverage doesn't work for us.
For our case we don't really care about branch-rate. I just need the line rate out.
image

But I am getting weird results back.

@vincent-fuchs
Copy link

Hi,

I thought I had the same issue, but actually was able to understand that I wasn't comparing the same thing.. Here's how I found it out :

With an aggregated jacoco.xml report (generated with jacoco 0.8.1 and report-aggregate goal) :

  • the html version of the report generated by Jacoco gives an overall 82% instruction coverage --> 1,265 of 7,335 instructions are missed.

  • when taking the equivalent jacoco.xml and feeding it to Jacoco parser (with a new test in JacocoParserTest pointing to my jacoco.xml), I get 75.11% line coverage. with additional logs, I see that
    lines missed : 532.0
    lines covered : 1606.0

--> The coverage that Jacoco displays in the HTML report in the first column is the "instructions coverage"

image

But if you see in later columns, there's a lines section showing 2138 total and 532 missed : this is the data that JacocoParser feteches and uses (2138 - 532 = 1606 covered).

So if we are expecting the plugin to show the instructions coverage, then it will very often not macth the expected result, because the plugin is showing the lines coverage

==

maybe that could be a new feature : being able to specify which one we want the plugin to show - information is readily available in xml, it's just a minor change in the Xpath expression :

image

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

4 participants