I am using clover with ant to generate coverage reports to an existing java project that already has unit test cases.
My ant target first runs clover-setup then builds the code using javac and then runs the tests using junit. I have added clover.jar to the runtime classpath for the test cases.
When i run the build target i see clover logs saying that classes have been instrumented
[clover] Clover all over. Instrumented 28 files (3 packages).
However when i run the <clover-html-report> task no report is generated. Instead the log shows
[clover-html-report] No coverage recordings found. No report will be generated.
If code coverage is being collected/logged what log messages am i expected to see when junit is executing?
1) Please check in which order your targets are being called. A common mistake is to call <javac> first, followed by <clover-setup>. As a consequence, sources are instrumented, but not compiled. Assuming that you're using Clover-for-Ant, a typical sequence is:
2) Please double check if the clover.jar is on the classpath. In case it's missing you may find "NoClassDefFoundError" exceptions in the junit log.
3) Please check if clover.db is accessible by your application during test execution. It may happen that instrumented classes cannot find the database, especially when unit tests are ran from a working directory different than the build directory or on another machine.
In such case you shall find warning messages in the junit log about it.
How to fix it? You can:
* use an absolute path in <clover-setup initstring="..."> or
* run unit tests from the same working directory as build or
* copy clover.db to a proper location/machine and pass -Dclover.initstring=/path/to/clover.db JVM property
4) Please check what flush policy do you have in <clover-setup> set. You may change the default setting in case you're running your code on an application server.
The problem was that clover.jar was not on the classpath.
I had used a <classpath refid=""> in my junit task but that did not seem to work. If use the
<classpath> <pathelement location=""/> </classpath>
mechanism, then it works fine.
Thank you for your help
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
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!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG