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

Getting different clover coverage info

Abhinav Sahu June 10, 2014

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

0 votes
Answer accepted
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 10, 2014

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)

Abhinav Sahu June 10, 2014

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.

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 10, 2014

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

Abhinav Sahu June 10, 2014

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

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

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

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

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

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').

Abhinav Sahu June 16, 2014

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
TAGS
AUG Leaders

Atlassian Community Events