Jacoco:聚合多个测试用例方法的分支覆盖率报告

Jacoco: Aggregating branch coverage report of multiple test case method

我正在使用 Ant JUnit。

<for list="${test.classes.list}"  param="class" delimiter=",">
<sequential>
    <for list="${@{class}}"  param="method" delimiter=",">
        <sequential>
            <jacoco:coverage destfile="${basedir}/jacoco.exec">
            <junit fork="true">
                 ......
                <test name="@{class}" methods="@{method}"/>
            </junit>
            </jacoco:coverage>
            <jacoco:report>     
                ......
                <csv destfile="coverage/@{class}.@{method}/report.csv"/>
            </jacoco:report>
        </sequential>
    </for>
</sequential>

在 属性 文件中,我有:

test.classes.list=a.b.C,d.e.F
a.b.C=test1,test2
d.e.F=test1,test2,test3

Jacoco 将为每个测试用例方法生成一份报告。

问题是每个 class 的分支覆盖不准确,因为覆盖的分支可能重叠。

如何汇总报告以获得整个项目的正确分支覆盖率?

JaCoCo 附带 Ant tasks to launch Java programs with execution recording and for creating coverage reports from the recorded data. Execution data can be collected and managed with the tasks coverage, agent, dump and merge

这是来自其网页的示例,说明如何合并一组 *.exec 个文件:

<jacoco:merge destfile="merged.exec">
    <fileset dir="executionData" includes="*.exec"/>
</jacoco:merge>