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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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
TAGS
Community showcase
Published in Trello

📹 What is a Trello board?

Hi, Atlassian Community! My name is Brittany Joiner and I am a Trello enthusiast and Atlassian Community Leader. I'll be sharing with you a series of videos with my top tips on how to best use Tre...

2 views 0 2
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you