简体   繁体   中英

How to group classes from Jacoco report using Ant

I'm using Jacoco with Ant to generate code coverage reports for classes from a few modules.

sourceDir/

  • module1/
    • target/classes/class11
    • target/classes/class12
  • module2/
    • target/classes/class21
    • target/classes/class22

Ant task: ...

<property name="src.dir" location="sourceDir"/>

<target name="report">
    <jacoco:report>

        <executiondata>
            <file file="${result.exec.file}" />
        </executiondata>

        <structure name="JaCoCo Report">
            <classfiles>
                <fileset dir="${src.dir}" includes="**/target/classes/**" />
            </classfiles>
            <sourcefiles encoding="UTF-8">
                <fileset dir="${src.dir}" />
            </sourcefiles>
        </structure>

        <html destdir="${result.report.dir}" />
        <csv destfile="${result.report.dir}/report.csv" />
        <xml destfile="${result.report.dir}/report.xml" />
    </jacoco:report>
</target>

Running Ant task I get a report similar to this:

Report

  • class11
  • class12
  • class21
  • class22

Would like to get something like this:

Report:

  • module1/
    • class11
    • class12
  • module2/
    • class21
    • class22

Quoting documentation at http://www.jacoco.org/jacoco/trunk/doc/ant.html :

The structure can be refined with a hierarchy of group elements. This way the coverage report can reflect different modules of a software project. For each group element the corresponding class and source files can be specified separately. For example:

 <structure name="Example Project"> <group name="Server"> <classfiles> <fileset dir="${workspace.dir}/org.jacoco.example.server/classes"/> </classfiles> <sourcefiles> <fileset dir="${workspace.dir}/org.jacoco.example.server/src"/> </sourcefiles> </group> <group name="Client"> <classfiles> <fileset dir="${workspace.dir}/org.jacoco.example.client/classes"/> </classfiles> <sourcefiles> <fileset dir="${workspace.dir}/org.jacoco.example.client/src"/> </sourcefiles> </group> ... </structure>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM