why does clover html report show non-instrumented code?

I am using maven-clover plugin 3.1.12 for generating coverage reprot for our functional tests. In my pom file, I exluded some classes from instrumentation. I checked target/clover/src-instrumented directory and verified that they were not instrumented (they don't have "This file has been instrumented by Clover ..." line). However when clover generates the html report, it still shows those classes with 0% coverage and that brings down our overall coverage. What do I need to do to exclude these classes from html report and overall coverage calculation?

1 answer

0 vote

I suspect that you do not delete the Clover database (clover.db) between builds and thus Clover still "remembers" that such class is present. And because of the fact that it's no longer instrumented, it shows 0% coverage for it.

If you keep clover.db in a standard location (in target subdirectory), then a standard 'mvn clean' should help.

Thanks Marek, your theory is correct. Clover.db is not getting deleted. I see the following line in our hudson log when I run "mvn clean clover2:setup ....."

Updating existing database at '/home/<user>/tmp/clover/db/clover.db'

I added clover2:clean, but I still didn't get

Creating new database at '/home/<user>/tmp/clover/db/clover.db'



Then I changed clover.instrumented.db to /tmp/db/clover.db

the first time I ran my hudson job, I got

Creating new database at '/tmp/db/clover.db'

but when I ran the same job for the second time, clover again started updating the exiting file instead of creating a new one

Updating existing database at '/tmp/db/clover.db'

[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ managed-ledger --- [INFO] Deleting /home/.../target
[INFO] 
[INFO] --- maven-clover2-plugin:3.1.12:clean (default-cli) @ managed-ledger --- [INFO] 
[INFO] --- maven-clover2-plugin:3.1.12:setup (default-cli) @ managed-ledger --- [INFO] Clover Version 3.1.12, built on June 27 2013 (build-899)
[INFO] Loaded from: /home/<user>/tmp/m2-repository/com/cenqua/clover/clover/3.1.12/clover-3.1.12.jar
[INFO] Clover: Commercial License registered to ...
[INFO] Updating existing database at '/tmp/db/clover.db'.
[INFO] Processing files at 1.6 source level.
[INFO] Clover all over. Instrumented 32 files (3 packages).
[INFO] Elapsed time = 0.552 secs. (57.971 files/sec, 11,840.58 srclines/sec)

Is there any reason clover2:clean doesn't remove the exiting file when clover.db is not in its standard location?

The clover2:clean has a <keepDb> option (default is false), can you confirm that you didn't set it to true?

Could you run 'mvn -X clover2:clean'. The debug logging should show which files/directories are being removed by clover2:clean (it removes the cloverOutputDirectory - see source code).

I have a similar issue, my database file is located under target maven directory but in log file there is no message of create new database file.

Only Updating existing database at ...I have the same problem. I have excluded files but they are still exists in the report and reduce the coverage.

It seems like something is wrong on my hudson slave. When I run clover on my local box, everything works fine. Basically clover creates a new file everytime I run it.

I don't set keepDb flag option.

As a workaround , I added rm command to my driver script.

@Nava:

  • you can call 'mvn clean' to remove the database and coverage files
  • you can also define exclusion patterns for reporting (clover2:clover + reportDescriptor)

@Kevin:

Have you tried 'mvn -X'? Which directory is being removed by clover2:clean? I'd bet it's trying to empty <project dir>/target/clover instead of /home/<user>/tmp/clover/db/ (or /tmp/db).

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published yesterday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

39 views 0 3
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