Closed Khaseyama closed 6 months ago
Hi, it seems that while JaCoCo supports branch coverage, it's not exactly translatable to what coveralls expects. I might take a look at it if I get some time, but it may not be trivial to implement an/or give the desired information on branch hits/misses.
+1
Hi, @nbaztec, @snackattas.
From the coveralls.io side, let us know if we can help with the implementation.
In case it helps as a reference, I've attached an example of a Coveralls JSON-format Coverage Upload (the JSON file any Coveralls integration ultimately POST
s to https://coveralls.io/apio/v1/jobs
):
Coveralls JSON-format Coverage Upload Example (4 files only) - 2024-03-18T100620.241.json
In this example I've removed all but the first four (4) files in the source_files
collection. The first two files have branch coverage stats; the second two do not (thus the empty branches
collection on those).
In a Coveralls JSON-format coverage report, branch coverage is represented under the branches
key within each entry in source_files
. This key contains an array of numbers that represent the coverage data for branches in the source code. Each group of four numbers in this array represents a single branch point in the code, structured as follows:
For example, consider the first entry under the branches
key for lib/enterprise.rb
:
This indicates that at line 43 in the lib/enterprise.rb
file, there are several branches (identified as branches 1, 2, 3, 4 in block 0), and none of these branches were executed during testing (as indicated by the 0 hits).
Let me know if you have any questions.
Thanks @afinetooth this is certainly helpful.
Since jacoco generates a report per line, where nr: line number
, mb: missed branches
, cb: covered branches
, in the example below, the line 7
has 1
missed branch and 2
covered branches:
<sourcefile name="Foo.kt">
<line nr="7" ... mb="1" cb="2"/>
</sourcefile>
I presume I can expand the branch entries requested by coveralls, as such:
{
...
"branches": [
7,0,1,0, // mb1
7,0,2,1, // cb1
7,0,3,1, // cb2
],
...
}
and that will generate the correct/equivalent coverage.
@Khaseyama I wanted to verify branch coverage before the 1.2.20
release once but didn't get around it. Could you please verify if it works for you now?
@nbaztec
@Khaseyama I wanted to verify branch coverage before the
1.2.20
release once but didn't get around it. Could you please verify if it works for you now?
thank you, I'll check. It may take a while.
@nbaztec I have confirmed that branch coverage is displayed in Coveralls in ver1.2.20. Thank you!
I was able to display Line coverage using coveralls-jacoco-gradle-plugin and circleCI. But I don't see branch coverage. Branch coverage was visible when I don't use coveralls-jacoco-gradle-plugin. Can coveralls-jacoco-gradle-plugin be made to show branch coverage?
https://docs.coveralls.io/api-jobs-endpoint#:~:text=JSON%20OBJECT%3A%20SOURCE%20FILE