How to get coverage reports when there is no coverage

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

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"/>

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

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="...">.

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;

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?

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
Community showcase
Published Wednesday in Opsgenie

Getting the Most out of Atlassian and Opsgenie Together

We’re excited to invite you to this action-packed webinar where we will demonstrate how to integrate Opsgenie’s powerful alerting and on-call management tools with your entire Atlassian stack. Mar...

68 views 0 1
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you