Getting different clover coverage info

Hi,

I am getting different code-coverage values when using ANT task and when running through JAVA. I am getting 44 % through ANT and 56 % through Java commandline execution for a clover report.

I am ruuning:

For ANT:

<target name="clover.html">

<delete dir="/home/as185127/results" />

<mkdir dir="/home/as185127/results" />

<clover-report initString="/home/ta230208/coverage.db">

<current outfile="/home/as185127/results" summary="true">

<format type="html" srcLevel="false" showEmpty="true"/>

</current>

</clover-report>

</target>

For Java:

java -classpath ${cloverhome}/clover.jar com.cenqua.clover.reporters.html.HtmlReporter -i ${testsdbfilesdir}/home/ta230208/coverage.db -o ${testshtmldir}/ -h -e

cp -r ${testshtmldir}/* ${teamcityworkdir}/artifacts/html

Please let me know why I am getting this difference?

All my coverage db files are in /home/ta230208

Thanks & Regards,

Abhinav

1 answer

1 accepted

Accepted Answer
0 votes

Are you using the same database? In <clover-report> you have:

/home/ta230208/coverage.db

while in HtmlReporter you have:

${testsdbfilesdir}/home/ta230208/coverage.db

so they point to different databases (unless the ${testsdbfilesdir} is empty)

Yes the database location is same.

we are running complete commands from shell as:

#copy first the db file

echo "Copying the clover dbfiles generated .."

zipcloverfiles=`sh ${commondir}/nodecmd ${targethost} "zip -r ${targetmachinetemppath}/clovertemp.zip ${targethostcloverdbfiles}"`

noderemotefilescp=`sh ${commondir}/noderemotescp ${targethost} ${targetmachinetemppath}/clovertemp.zip ${testsdbfilesdir}`

unzipcloverdbfiles=`cd ${testsdbfilesdir};unzip ${testsdbfilesdir}/clovertemp.zip`

#clover coverage report.

echo "Gathering clover coverage...."

java -classpath ${cloverhome}/clover.jar com.cenqua.clover.reporters.html.HtmlReporter -i ${testsdbfilesdir}/home/ta230208/coverage.db -o ${testshtmldir}/ -h -e

cp -r ${testshtmldir}/* ${teamcityworkdir}/artifacts/html

#end clover coverage

thanks again.

What file pattern do you have in ${targethostcloverdbfiles}?

Hi Marek,

Thanks for your quick responses, I am analysing the directories. I think there are mismatch in number of coverage files.

One more query, do these coverage files like, coverage.db156znf_hvfkmid5, coverage.dbi3izfe_hvfki29b, coverage.dbi3izfe_hvfkqip5.1, etc are always unique by name? Means suppose if I have executed coverage a month ago and then ran coverage today, then would there be possibility that few of these db files are same??

Regards,

Abhinav

Global coverage files (like coverage.db156znf_hvfkmid5) are rather unique. Their name consists of:

<databasename.db><coverage recorder instance>_<coverage timestamp>

I think there are mismatch in number of coverage files.

If number of coverage files is different, then possible causes are:

1) Code has been recompiled with different classes/modules in scope.

2) Different set of tests was executed.

3) Project structure has changed (e.g. number of modules has changed, build files were modified).

4) Some coverage recording files were not written to disk (e.g. process was terminated by kill -9).

5) Wrong flush policy is used (e.g. application is running on a server which is not terminated after tests and at the same time a flush policy is set to 'directed').

Hi Marek,

Yes I think we are doing 1 & 2 steps in our project. I will resolve these and let you know for any issues.

Thanks again for your valuable answers.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted 2 hours ago in Europe

Topic Tuesday: Pizza Toppings

Today we're off to Canary Wharf for our next event at Moody's  Investors Service, so I hope you can all make it. Please RSVP here if you can: https://aug.atlassian.com/events/deta...

10 views 0 0
View post

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