My team has set up code coverage reporting for our project. It is a golang project and we are generating cover.out files in the gocov format. We noticed some weird looking files in our report
I am also attaching a screenshot of the relevant section in case the report is changed by future builds:
There are a couple of things to be noted there:
line 39 looks like it is not a statement, while actially it is
line 47 is reported as covered, but line 48 is reported as not covered, which is impossible, because they are two adjacent lines in the same conditional statement - they should either be both covered or both not covered
line 43 and line 50 both consist of a closing brace ({). Line 50 is displayed as a statement that is not covered, while line 43 is displayed as a non-statement, which is inconsistent.
We took a look at our raw cover.out file, which is in gocov format and it looks fine to us. Here is a screenshot of the same section of the code as displayed by the html report generated by go tool cover -html=cover.out:
As you can see none of the above mentioned anomalies are present, meaning that the cover.out file is generated correctly.
We went a bit further and converted the raw file to the codeclimate format using the latest test reporter. Here is the relevant section of the json file:
We interpreted the coverage key of that json a a bitmap, each element corresponding to a line, where null is not a statement and a number means that the line is a statement and represents how many times the statement is visited. This interpretation aligned perfectly with the first screenshot above and confirmed our suspicion that the test reporter is not formatting the cover.out correctly.
Here is the full cover.out file for more detailed information:
cover.out.txt
Hello there,
My team has set up code coverage reporting for our project. It is a golang project and we are generating
cover.out
files in thegocov
format. We noticed some weird looking files in our reportI am also attaching a screenshot of the relevant section in case the report is changed by future builds:
There are a couple of things to be noted there:
{
). Line 50 is displayed as a statement that is not covered, while line 43 is displayed as a non-statement, which is inconsistent.We took a look at our raw
cover.out
file, which is ingocov
format and it looks fine to us. Here is a screenshot of the same section of the code as displayed by the html report generated bygo tool cover -html=cover.out
:As you can see none of the above mentioned anomalies are present, meaning that the
cover.out
file is generated correctly.We went a bit further and converted the raw file to the codeclimate format using the latest test reporter. Here is the relevant section of the json file:
We interpreted the
coverage
key of that json a a bitmap, each element corresponding to a line, wherenull
is not a statement and a number means that the line is a statement and represents how many times the statement is visited. This interpretation aligned perfectly with the first screenshot above and confirmed our suspicion that the test reporter is not formatting thecover.out
correctly.Here is the full
cover.out
file for more detailed information: cover.out.txt