Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get coverage reports when there is no coverage

Deleted user May 14, 2014

I have a product written in Java where I have many (over 250) separately-instrumented modules. Unfortunately, many of these modules have no coverage generated during our tests. However, I still need a coverage report generated for them, so that I have an accurate count of the total number of lines that are not covered in our product. Otherwise, I want exactly the same report that the clover-html-report ant task generates. It must be exactly the same because (a) people have gotten used to the report format, and (b) I run an XSLT to parse the summary HTML files to extract the actual coverage numbers I need for the product-wide summary that I generate.

I see that the clover-report task has an "alwaysReport" option, but it seems I can't use that without having to define the entire report format (including the columns, etc.), plus there doesn't seem to be a way to specify the outdir parameter.

Is there a way to convince clover-html-report to write out reports even when there is no coverage?

2 answers

1 accepted

0 votes
Answer accepted
Deleted user May 27, 2014

OK, here is exactly what I needed in order to produce exactly the same reports, with the only change being that the reports are always generated:

<clover-report initstring="${build.coverage.clover.dbdir}/${build.number}/@{module}/clover.db" coverageCacheSize="128m" >
	<current alwaysReport="true" outfile="${html.dir.local}/${build.number}/@{module}" title="Coverage for module @{module}">
		<format type="html"/>
	</current>
</clover-report>

The only problem now is that the reports for modules with no coverage end up with a date of 1/1/1970. Completely understandable - with no coverage, where would it remember a date? However, it would be better if it at least tried to use the same date as when the report was run.

0 votes
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 14, 2014

The <clover-html-report> does not have the alwaysReport option. It means that you'd have to use a <clover-report> instead.

The <clover-report> task has an option to set the output directory - use the <current outfile="..."> or the <historical outfile="...">.

Deleted user May 14, 2014

So, if I change this:

&lt;clover-html-report initstring="${build.coverage.clover.dbdir}/${build.number}/@{module}/clover.db" outdir="${html.dir.local}/${build.number}" title="Coverage for module @{module}" coverageCacheSize="128m" /&gt;

to this:

&lt;clover-report initstring="${build.coverage.clover.dbdir}/${build.number}/@{module}/clover.db" coverageCacheSize="128m" &gt;
  &lt;current alwaysReport="true" outfile="${html.dir.local}/${build.number}" title="Coverage for module @{module}" /&gt;
&lt;/clover-report&gt;

then I should get the same reports that I corrently do, with the addition of the empty reports?

One of the confusing things in the documentation: the "current" nested element says that the default format is XML, but the "format" nested element says that it is is omitted, an HTML report is generated. Which is it?

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 14, 2014

Indeed, documentation was confusing, I just fixed it.

When the <current> has the summary="true" then the default format is PDF, otherwise it's XML.

You can change a report type by defining the <format type="html|pdf|xml|json"> tag inside the <current> (or the <historical>).

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events