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

Problem with Per Test Coverage

Hi,

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="${coverage.merge.data.dir}/merged.db">
    <testsources dir="${core.home}/pathtotestsrccode/">
      <include name="*.java" />
      <include name="**/*.java" />
      <testclass>
        <testmethod name="test.*"/> 
      </testclass>
    </testsources>
  </clover-setup>
</target>

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.

Thanks,
Serena

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 ${coverage.merge.data.dir} 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.

Serena

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Happy New Year and Welcome New Marketplace Partner Program Partners!

Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...

442 views 5 16
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