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

Clover instrumented classes generated in wrong directory

Scott April 25, 2014

I have the following ant configuration. I am trying to get the instrumented classes separate from the actual compiled classes. I still see the instrumented classes in the destdir of javac target instead of the desdir of clover-instr. Please help.

<target name="with.clover">
      <clover-setup initstring="${clover.db}" />
      <clover-instr destdir="${build.dir}/clover/instrumented-classes" srcdir="${app.dir}/src" initstring="${clover.db}" />
    </target>
    <target name="compile" depends="with.clover">
        <javac destdir="${webinf.dir}/classes" srcdir="${app.dir}/src" debug="true" sourcepath="">
            <classpath refid="app.classpath" />
            <include name="**/*.java" />
        </javac>
    </target>

3 answers

0 votes
Scott April 29, 2014

found the problem. had to move the instrumented classes to be first in the classpath.

0 votes
Scott April 25, 2014

tried that and I'm getting the following error

[clover] Processing files at 1.7 source level.
[clover] Double instrumentation detected: C:\EclipseWorkspaces\ScaleDataProvider.java appears to have already been instrumented by Clover.
[clover] ** Error(s) occurred and the instrumentation process can't continue.

BUILD FAILED

0 votes
Boris Georgiev _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 25, 2014

I think the problem here is that you're not compiling the instrumented source but the non-instrumented one.

destdir - The directory into which Clover will write an instrumented copy of the source code.

So try that one:

<target name="with.clover">
<clover-setup initstring="${clover.db}" />
<clover-instr destdir="${build.dir}/clover/instrumented-classes" srcdir="${app.dir}/src" initstring="${clover.db}" />
</target>
<target name="compile" depends="with.clover">
<javac destdir="${webinf.dir}/classes" srcdir="${build.dir}/clover/instrumented-classes" debug="true" sourcepath="">
<classpath refid="app.classpath" />
<include name="**/*.java" />
</javac>
</target>

Scott April 25, 2014

tried that and I'm getting the following error

[clover] Double instrumentation detected: C:\EclipseWorkspaces\ScaleDataProvider.java appears to have already been instrumented by Clover.
[clover] ** Error(s) occurred and the instrumentation process can't continue.

BUILD FAILED

Boris Georgiev _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 25, 2014

Why do you call clover-instr ? This should not be required as clover-setup replaces the standart javac and when you call javac your classes will actually get instrumented.

So I think you need to either remove clover-setup or clover-instr.

<target name="with.clover">
      <clover-setup initstring="${clover.db}" />
  </target>
    <target name="compile" depends="with.clover">
        <javac destdir="${build.dir}/clover/instrumented-classes" srcdir="${app.dir}/src" debug="true" sourcepath="">
            <classpath refid="app.classpath" />
            <include name="**/*.java" />
        </javac>
    </target>

Do you need to have a non-instrumented classes on one place and instrumented on another ? In that case you should call javac to compile without instrumentation before calling clover-setup I think and then after clover-setup is called again call javac to compile with instrumentation.


Scott April 28, 2014
here is the build script.

	<path id="instrument.build.classpath">
           .....
 <pathelement path="${clover.jar}"/> </path> <path id="test.classpath"> <path refid="instrument.build.classpath" />
.... </path> <target name="with.clover"> <clover-setup initstring="${clover.db}" /> </target> <target name="instrument" depends="prepare,with.clover" > <javac destdir="${instrument.dest.dir}" srcdir="${src.base.dir}/src" debug="true" sourcepath=""> <classpath refid="instrument.build.classpath" /> <include name="com/app/**/*.java" /> </javac> </target> <target name="clean"> <clover-clean initstring="${clover.db}" /> </target> <target name="prepare" depends="clean"> <mkdir dir="${test.classes.dir}" /> </target> <target name="testCompile" depends="instrument" description="Compiles the test classes from ${test.src.dir} to ${test.classes.dir}"> <javac srcdir="${test.src.dir}" destdir="${test.classes.dir}" includeantruntime="false" deprecation="on" debug="on" debuglevel="lines,vars,source" verbose="true" compiler="modern" encoding="latin1" > <classpath refid="test.classpath" /> </javac> </target> <target name="test" depends="testCompile"> <taskdef name="testng" classpath="${testng.jar}" classname="org.testng.TestNGAntTask" /> <testng haltOnfailure="true" listeners="com.app.common.TestListener" outputdir="${test.output.dir}" classpathref="test.classpath"> <xmlfileset dir="${test.classes.dir}/testsuite" includes="unittestng.xml" /> </testng> <!-- Run clover coverage report in html format --> <clover-html-report outdir="${coverage.results.dir}" title="Clover Report" initstring="${clover.db}" /> </target>

Scott April 28, 2014

I separated the compilation for non-instrumented and instrumented classes. I do see the classes being instumented and clover.db getting created, but when I run the tests, I don't see the coverage files getting generated which is resulting in zero coverage.

[clover-html-report] Loading coverage database from: 'C:\EclipseWorkspaces\build\testng\build\clover\db\clover.db'
[clover-html-report] No coverage recordings found. No report will be generated.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events