-
Notifications
You must be signed in to change notification settings - Fork 1
UsageTipsAndTricks
This is a collection of tips and some not so obvious tricks for using JaCoCo. The ideas have been collected and verified in different projects where JaCoCo helps to monitor test coverage. This should become part of JaCoCo documentation.
Do you run a modular build with several separate test suites? In this case set the sessionid
property of the JaCoCo agent or the coverage
Ant task with e.g. the name of the test component. This information will then be included in the report (e.g. on the "Session" page of the HTML report) and clearly document the source of the execution data shown in the report. The JaCoCo build itself uses this technique, see its session page.
Reports may not only be grouped by Java packages. With group
tags within the report
Ant task arbitrary hierarchies can be defined above the package level. This allows to reflect your product structure (modules, bundles, features etc.) and results in comparable summaries for the individual groups. The [report](http://www.eclemma.org/jacoco/trunk/coverage/index.html JaCoCo) itself is structures in this way to get separate values for each bundle.
The JaCoCo Ant tasks fully utilize Ant's resource collection types. Any resource collection might serve as input for class files, source files or execution data. So for example it is possible to collect source files from source archives. The following example picks the Java sources of the Equinox OSGi implementation from the corresponding source archive:
<sourcefiles>
<zipfileset includes="**/*.java">
<fileset dir="${target.plugins.dir}" includes="org.eclipse.osgi.source_*.jar" />
</zipfileset>
</sourcefiles>
You can create a coverage report without specifying execution data at all - which will result in 0% coverage. Why should anyone do this? The report still provides some interesting metrics about the code base, for example the effective lines of code. When compiled with debug information this is possible even if don't have the corresponding sources.
TODO