code-coverage-api-plugin icon indicating copy to clipboard operation
code-coverage-api-plugin copied to clipboard

MergeToOneReport for same lines from different reports fails.

Open vaibhav-46 opened this issue 5 years ago • 2 comments

I have set up my jacoco reporting in a way such that the unit test coverage and the integration test coverage is generated separately for each of the modules in the project. For example, if there are 2 modules, the jacoco xml reports are as follows:

Project
  -> module1
       -> src
       -> target
           -> unitTests.xml
           -> integrationTests.xml
   -> module2
        -> src
        -> target
           -> unitTests.xml
           -> integrationTests.xml

What I would like is to get the overall code coverage after merging the 4 xml files as specified above. Using the mergeToOneReport does work, but I am seeing errors in certain cases where the same function is covered differently in the unitTests and the integrationTests. For example, consider the following snippets taken from one of the runs:

unitTests.xml sample

<class name="RequestHandler" sourcefilename="RequestHandler.java">
<method name="<init>" desc="(L/sessionstore/SessionStore;)V" line="70">
<counter type="INSTRUCTION" missed="0" covered="6"/>
<counter type="LINE" missed="0" covered="3"/>
<counter type="COMPLEXITY" missed="0" covered="1"/>
<counter type="METHOD" missed="0" covered="1"/>
</method>

integrationTests.xml sample

<class name="RequestHandler" sourcefilename="RequestHandler.java">
<method name="<init>" desc="(L/sessionstore/SessionStore;)V" line="70">
<counter type="INSTRUCTION" missed="6" covered="0"/>
<counter type="LINE" missed="3" covered="0"/>
<counter type="COMPLEXITY" missed="1" covered="0"/>
<counter type="METHOD" missed="1" covered="0"/>
</method>

Note that I have intentionally removed some identifiable information, but the two have the exact same class, path and function descriptions. Eventually, when the report is generated the code coverage for this entire file is 0 even though the coverage in the unitTests.xml file is non-zero. The funny thing is that this is non-deterministic. In some runs, the numbers do show up correctly and I have coverage. Essentially with no code change, my coverage graph keeps fluctuating (as shown in the image below) which makes me think that the mergeToOneReport is not working deterministically.

image

Thanks.

vaibhav-46 avatar May 16 '20 20:05 vaibhav-46

Seeing same issue

Mulgish avatar Sep 21 '21 15:09 Mulgish

I wonder if this feature should be removed totally? Since JaCoCo can merge reports on its own I see no argument why we should reimplement the same thing.

uhafner avatar Jan 15 '22 23:01 uhafner

The new step recordCoverage is now in beta testing, can you please check if this release helps to solve this issue? Please note that the syntax of the step is totally new and cannot be combined with existing results.

uhafner avatar Mar 15 '23 21:03 uhafner

@uhafner Can you clarify if mergeToOneReport was removed just for JaCoCo or for all parsers? Is merging the default behavior or is merging no longer supported since it's not a configurable option for recordCoverage (as far as I can tell)?

ay-azara avatar Jun 22 '23 15:06 ay-azara

@uhafner Can you clarify if mergeToOneReport was removed just for JaCoCo or for all parsers? Is merging the default behavior or is merging no longer supported since it's not a configurable option for recordCoverage (as far as I can tell)?

Merging is now the default operation for two coverage reports with the same structure. It is provided by the model and not dependent on the parser.

uhafner avatar Jun 22 '23 19:06 uhafner