tags:

views:

180

answers:

1

Hello I am a Java web app developer

I have a problem, I would like to make clover collect data during runtime for my web applications.

I did manage to do so for a single application by adding a parameter to my tomcat (-Dclover.initstring.basedir="[PATH TO CLOVER DB]" ).

It worked fine.

But the problem is that we have more than one application and I would like to check their data coverage during runtime, all at once.

So I have tried to do the same by referring to a merged DB file. It doesn’t work - the merged db file just doesn’t get updated at runtime.

Do you have any idea why or any ideas on how should I do it?

Thank you

+2  A: 

Hi,

You have a few misconceptions here:

Firstly, clover db files are never updated at runtime - only ever updated at build time. Coverage data is recorded in separate files placed along side of .db files. The .db files record the structure of your project source and some other data needed by the running instrumented application.

Secondly, the only reason to merge a db is to (immediately after) perform a report on it. Once a .db is merged, no coverage can be collected for it. Merging is not appropriate before or during the running of an instrumented application. Only appropriate after.

Here's what you should do:

For each project (that corresponds to a webapp), add an explicit initstring that uniquely identifies the webapp. e.g. for webapp Foo have an initstring of foo.db, for webapp Bar have an initstring of bar.db etc

In project Foo's build.xml:

<clover-setup initstring="foo.db"/>

In project Bar's build.xml:

<clover-setup initstring="bar.db"/>

Now your webapps' .db file names will be unique so when you add -Dclover.inistring.basedir=/path/to/folder/containg/the/db/files/ each webapp won't trample on the other.

So after running your webapp, in /path/to/folder/containg/the/db/files/ you would expect to see something like this:

foo.db
foo.db9bl74u_g1e05ktv
foo.db9bl74u_g1e05ktv.1
bar.db
bar.db3wl21k_g1fbp9pb
bar.db3wl21k_g1fbp9pb.1

Once you're tested your webapps, you can then report on them. Here's when you might want to merge. You would merge if you wished to generate a single coverage report for all the webapps. There's normally no other reason to merge.

BTW: You'll probably get quicker answers over at forums.atlassian.com.

mrbaboo
The other way to do this is, assuming your webapps are all built at the same time, ensure your projects only use a single, shared .db file.If these different webapps are built separately then this won't work for you.
mrbaboo