I have two clover.db files; these clover.db files were created at two different times; but the underlying (instrumented) code did not change at all; I just compiled it twice; created two separate WAR files; and copied these two separate WAR files and clover.db to two separate servers.
After executing different tests against both of these deployed servers; and gathered up the clover.db* files.
I ran maven using mvn clover2:aggregate clover2:clover <options>
and got both sets of clover coverage files generated for each separate server. They result in some % of coverage (in this case, 14% and 19%)
Now, I want to aggregate these two into one report; but I can't seem to figure out how to do this; as every way I try (listed below) I end up with either 0% coverage or the coverage from a single server (Code Metrics for clover is filled out correctly).
Here's the various ways I've tried and the result:
Copy clover.db
from one server, and the clover.db*
files from both servers, and run mvn clover2:aggregate clover2:clover <options>
. This results in displaying only the coverage from one of the two servers (whichever one the initial clover.db
belongs to).
Copy clover.db
from both servers into a singular place (renaming the .db file to something unique). Running mvn clover2:aggregate clover2:merge <options>
. This results in a merged .db file (from what I can tell). I then use that merged .db file as the clover.db
file; copy in the clover.db*
files from both servers, and run mvn clover2:aggregate clover2:clover <options>
. I use the following in the pom.xml
file to indicate this merge:
<cloverMergeDatabase>/tmp/clover/Merged/newMerge.db</cloverMergeDatabase>
<baseDir>/tmp/clover/Merged</baseDir>
After this, I copy the newly created newMerge.db
to the location where mvn
is expecting the clover.db
file to be (and rename it to clover.db
since that is what mvn
is expecting). This is when I run the aggregate command. This results in displaying 0% coverage (the files get generated, but absolutely no coverage is indicated).
As you can see by the attached pictures, the files are being created correctly, it just isn't actually finding any coverage. First picture is when I do #1:
And the second is when I do #2:
Hopefully I've explained the issue I'm facing; but please if you think you can help but don't understand something I said ask questions. This is vexing me!
Merge at first point looks for Clover databases. Then it looks for coverage files matching database and it matches db filename with coverage file name. So e.g if db is named clover.db it will find all coverage files matching that name, like clover.db* (or analogically cloverdatabase -> cloverdatabase* <- coverage files)
In step one Clover most probably finds all coverage files, but those copied from second server doesn't match clover.db, so are discarded. (Clover saves informations about instrumentation and test execution sessions. Some of the metadata must match)
In step two when you rename second database all coverage files are matched against the first one (since name clashes) and then half of them is discarded because metadata doesn't match (the same mechanism like in step one). And since you have renamed second DB, Clover doesn't find any coverage files for that DB.
I can't be 100% here but it might not be enough just to rename files You can't simply rename files.
I'd suggest to generate databases with unique names e.g cloverWAR1.db, cloverWAR2.db. And then run tests, copy dbs to reporting machine for aggregation and report generation. You should use cloverDatabase property, like this. During test runtime you will probably have to specify location of db with a initstring property. That's because it's not default name and Clover won't be able to find it automatically.