Problem with Per Test Coverage


I am trying to do a per test coverage but I keep getting:

"No test results could be found. Please ensure that you have instrumented your unit tests correctly."

I am using the following for letting clover knows where the tests are:

<target name="coverage">
  <clover-setup initstring="${}/merged.db">
    <testsources dir="${core.home}/pathtotestsrccode/">
      <include name="*.java" />
      <include name="**/*.java" />
        <testmethod name="test.*"/> 

1. Is there a way to debug/see which tests clover knows?

2. Obviously I am doing something majorly wrong to get the functional per test coverage and your help shedding some light is greatly appreciated.


2 answers

1 vote

Hi Serena,

There are few things worth checking:

1) Merging databases

Do you merge Clover databases in your build (i.e. do you use <clover-merge> task)? I'm asking because I see that your database is named "merged.db".

If yes, then which databases (a merged or non-merged ones) do you use for test execution? Please note that a merged database can be used for reporting only. When do you merge them? Please note that merge operation shall be performed after test execution (i.e. when coverage recording files are created).

2) Custom test pattern in clover-setup

Do you see any tests detected during code instrumentation by Clover? In your build log you shall see messages like:

[javac] Compiling 3 source files to ...
[clover] Clover Version 4.0.0, built on July 11 2014 (build-917)
[clover] Updating existing database at '...\clover.db'.
[clover] Processing files at 1.7 source level.
[clover] Clover all over. Instrumented 3 files (1 package).
[clover] 11 test methods detected.

If you don't see "XX test methods detected." message for your test code, then it means that something is wrong with your <testsources> definition.

I suggest to check:

  • is the dir="${core.home}/pathtotestsrccode/" location correct? (use <echo message="..."/> to debug it)
  • is the <testmethod name="test.*"/> pattern correct?

3) Test sources in clover-report

If you see the "XX test methods detected" messages in your logs and the number of test methods seems to be correct and you still see no test results in your report, then please check your <clover-report> task - do you have the <clover-report>/<current>/<testsources> tag defined pointing to the ${core.home}/pathtotestsrccode"? If this location is not defined, then your test classes may end up on the "Application code" tab instead on the "Test code" tab.

4) Recording per-test coverage files

If you have the <clover-report>/<current>/<testsources> and still no-per test coverage, then please check if you see any *.s coverage recording files (e.g. "merged.dbabc_def_ghijk.s") in a directory where your Clover database is located (the ${} in your case).

If you see no such files - do you see at least global coverage files (they're shall be named like merged.dbabcd_efgh or merged.dbabcd_efgh.1)? If none of them are present then it means that you have a problem with coverage recording - the most probably:

- clover.db was not found (you shall see an error message in junit execution logs) or

- you have used merged database instead of a non-merged one (again, check junit logs)

Hi Marek,

Thanks for your reply. I ll investigate and let you know.


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

66 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