node-coveralls icon indicating copy to clipboard operation
node-coveralls copied to clipboard

Inaccurate Coverage Reported

Open wkirby opened this issue 8 years ago • 21 comments

Test coverage is being reported as:

Statements   : 100% ( 79/79 ), 3 ignored
Branches     : 96.15% ( 75/78 ), 12 ignored
Functions    : 100% ( 20/20 ), 1 ignored
Lines        : 100% ( 38/38 )

The travis build can be found here. The generated lcov.info file matches the reported output.

When viewing the coverage in Coveralls, the report shows only 63 of 78 branches covered, instead of 75 of 78 as shown in the lcov.info file, and project coverage of 86.957%.

wkirby avatar Mar 06 '17 01:03 wkirby

@wkirby could you upload your lcov file so I can see what's going on?

Thank you!

nickmerwin avatar Mar 06 '17 01:03 nickmerwin

@nickmerwin No problem. I had to change the extension to .txt to get it to upload, but this is what comes out of mocha when I run locally.

lcov.info.txt

wkirby avatar Mar 06 '17 02:03 wkirby

@nickmerwin Doing some math that I failed to do earlier, it looks like the 12 ignored branches are not ignored by coveralls (75-12 = 63). Is this intentional?

wkirby avatar Mar 06 '17 04:03 wkirby

I'm experiencing the same issue.. It reports stuff like:

import moment from 'moment'  // Branches [[2, 1], [8, 1], [10, 1], [12, 1]] missed.

Which is absolutely wrong

anehx avatar Mar 06 '17 14:03 anehx

@anehx I'm pretty sure these numbers are correct — behind the scenes the es6 is still being transpiled. Those ignored branches are ignored because they're the result of the transpiling.

The real issue, to me, seems to be that the actual report pushed to coveralls doesn't also ignore those branches, which results in a lower reported test coverage.

wkirby avatar Mar 06 '17 15:03 wkirby

I am also seeing the same issue. Here is an example: https://coveralls.io/builds/10518271

Coveralls is reporting: COVERAGE DECREASED (-3.6%) TO 85.523%

Here is the output from the Travis job: https://travis-ci.org/RackHD/on-tasks/jobs/209507039

istanbul reports:

===================== Coverage summary ===============================
Statements   : 89.19% ( 6422/7200 )
Branches     : 73.82% ( 1686/2284 )
Functions    : 86.29% ( 1598/1852 )
Lines        : 89.24% ( 6413/7186 )
=================================================================

geoff-reid avatar Mar 09 '17 21:03 geoff-reid

Hi @geoff-reid, we now factor branches into the overall coverage %, so that 85% is:

(1686 covered branches + 6413 covered lines) / (2284 branches + 7186 relevant lines)

nickmerwin avatar Mar 09 '17 21:03 nickmerwin

@nickmerwin Any luck on the original issue, where it appears ignored branches aren't being sent to coveralls correctly?

wkirby avatar Mar 09 '17 21:03 wkirby

@wkirby we're only passing along the BRDA:.. lines from the lcov.info, and I see 78 in your's but no indication of which should be ignored -- do you know where that's specified?

nickmerwin avatar Mar 09 '17 21:03 nickmerwin

I don't see anything that's output into the lcov.info file that would indicate which branches are hit or skipped, but the test suite is correctly outputting the BRF and BRH numbers at the end of the file.

I have no idea what the coveralls API expects, but does it allow sending up the BRF and BRH values in addition to the BRDA lines?

wkirby avatar Mar 09 '17 23:03 wkirby

@wkirby ok I see, so it looks like we'll need to add a BRH override parameter to the API. It's unfortunate that it won't be reflected in the source file view since all missed branches will be highlighted whether or not they were supposed to be ignored.

Maybe worth asking the lcov folks about that.

nickmerwin avatar Mar 10 '17 00:03 nickmerwin

For sure. I'm pretty confident that this is a side effect of testing an es6 class.

Our command using isparta in place of istanbul seems to transpile the es6 class in the background and flag the generated branches to be ignored. This is great for actually running the test, but, like you said, the generated lcov still has the branches in the final output file.

wkirby avatar Mar 10 '17 00:03 wkirby

I can confirm the issue, have been struggling to understand why suddenly coverage started misreporting since recently.

Turns out, the latest release broke it. All lines that were marked as istanbul ignore if and instanbul ignore next were suddenly included into the coverage on Coveralls, even though Travis CI reported the coverage correctly.

I've just downgraded to version 2.11.16, and the problem is gone.

vitaly-t avatar Mar 11 '17 12:03 vitaly-t

@vitaly-t Thanks! We bumped down to 2.11.16 and it fixed our coverage issue as well.

@nickmerwin On version 2.11.16 we're sending up the exact same lcov file, but getting a 100% coverage report from Coveralls. Something definitely changed with the 2.12.0 release that broke the ignored branch reporting.

wkirby avatar Mar 12 '17 09:03 wkirby

@nickmerwin was the change to include branches as part of the coverage calculation a patch release? It definitely changes functionality (some projects may have been setup to enforce 100% statements only) so was a bit surprising to see coverage % drop when no changes in code were made. Is there a way to control if lines and/or branches are included as the coverage calculation?

selfcontained avatar Mar 13 '17 19:03 selfcontained

@selfcontained we've added a toggle for this in the repo settings if you'd prefer to disable it:

image

nickmerwin avatar Mar 14 '17 04:03 nickmerwin

@nickmerwin shouldn't the default be the original behaivour? Everyone's code coverage got broken, and you just drop it in casually that everybody needs to update their projects?

vitaly-t avatar Mar 14 '17 13:03 vitaly-t

@vitaly-t that's a good point, while we wanted existing repo owners to be immediately aware of uncovered branches, it should be opt-in so as not to disrupt automated build workflows.

Moving forward we're going to opt-out all existing repos, and opt-in new ones by default.

nickmerwin avatar Mar 14 '17 16:03 nickmerwin

@nickmerwin does that mean it's on or off 😉 https://twitter.com/_simon__says/status/844106636235083777

(Kinda half sarcastic/half serious. Thanks for the tool 👍 )

leggsimon avatar Mar 29 '17 15:03 leggsimon

can we allow istanbul ignore using coveralls.yml without having to rely on the web UI? See discussion on https://github.com/lemurheavy/coveralls-public/issues/939

danday74 avatar Sep 29 '17 23:09 danday74

can someone help with how to interpret coverage report on coveralls and terminal? image image

davidshare avatar Sep 16 '18 09:09 davidshare