Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

-Dclover.inistring.basedir doesn't seem to be working

Andrew Collett December 11, 2013

I am using the above in java set_opts startup.bat, but the clover runtime data generation is happening in the original .db location, and not in location specified.

The .db specified by the init here is a merged blank database of a whole bunch of modules for one webapp.

Is there a reason clover would ignor the location I've specified?

I've read up on when to copy the db and so on, and that you shouldnt merge if you intend to add more to the db, but does this applywhen merging only the blank database (only the .db file)?

Can someone explain why clover might ignore this setting, and what it may do, and whether my assumptions on the merge are correct or not.

2 answers

1 accepted

1 vote
Answer accepted
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 11, 2013

Hi Andrew,

Few hints about debugging problems with initstring. If you run an application with -Dclover.logging.level=verbose you shall see one of the following messages in a log file:

"overriding initstring: <init string>" - if -Dclover.initstring property is declared

"overriding initstring basedir: <init string base dir>" - if -Dclover.initstring.basedir is declared

"prepending initstring prefix: <prefix>" - if -Dclover.initstring.prefix is declared

In case you have some security restrictions applied, which forbid accessing system properties, a following message is logged:

"Failed to retrieve Clover properties: clover.initstring*" (with a SecurityException stack trace)

Cheers
Marek

Andrew Collett December 11, 2013

Hello Marek,

Thank you for the help, now on the right road again.

I'm having an issue that I'm not getting that output (in log from setting -Dclover.initstring.basedir) you mentioned I should get. I'm confident that the verbose output is on, as I'm getting other verbose output I didnt get before.

Does the initString need to be set at compile time, in Maven2 (cloverDatabase?) in order for the option to activated?

I.e. If I dont set the cloverDatabase, (as setting it also then makes one DB, instead of the blank one with seperate files, and I cannot get the DB before the tests runs), will the -Dclover.initstring.basedir still work as described?

Thanks in advance,

Andrew

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 11, 2013

Hi Andrew,

The -Dclover.initstring, -Dclover.initstring.basedir, -Dclover.initstring.prefix are runtime properties which shall be passed to an application instrumented by Clover. These runtime properties will override inistring value which is hardcoded in instrumented code (and which was declared in the pom.xml).

Do not confuse them with a compile-time Maven properties, which can be passed to certain MOJOs. A good is example of such property is -Dmaven.clover.cloverDatabase which is being passed to the clover2:setup <cloverDatabase> property.<tt>
</tt>

It means that you shall declare -Dclover.initstring.basedir for application or test execution (for instance in the maven-surefire-plugin <jvm> property when fork is enabled), rather than as a mvn command parameter.

Regards
Marek

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 11, 2013

Does the initString need to be set at compile time, in Maven2 (cloverDatabase?) in order for the option to activated?

If you don't declare the <cloverDatabase> for maven-clover2-plugin in pom.xml, then the default value is used (target/clover/clover.db). Typicall, Clover will produce one database file per Maven module, unless the <singleCloverDatabase> is set to true - in such case it will defer creation of the database file till compilation of the last module and store the db file in this module.

The <cloverMergeDatabase> parameter, on the other hand, is used by the clover2:aggregate goal, which merges database for reporting.

The initstring set at the compile time (<cloverDatabase>) is independent from the initstring set at runtime (-Dclover.initstring). The latter one overrides a value set during compilation.

... and I cannot get the DB before the tests runs

I didn't get the point. Could you please elaborate what you're trying to achieve?

Andrew Collett December 12, 2013

Hello Marek,

Just a report back:

Managed to get everything to work as we wanted. Between spelling mistakes (coders nemisis, i had inistring and not initstring) and just not quite understanding how clover works, I was struggling.

But your excelent answers and feedback helped us figure out how to get it all working!

Seperate clover .db's with different names was the way to go. Clover is impressivly intelligent.

Thanks a lot.

1 vote
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 11, 2013

Hi Andrew,

You cannot use a merged database for code coverage recording.

A merged database can be used for report generation only.

Reference:

Cheers
Marek

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events