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

Accepted Answer
0 votes

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

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;
&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?

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 Monday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

392 views 0 8
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