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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Clover instrumented classes generated in wrong directory

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

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>

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

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.


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>

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.

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

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Happy New Year and Welcome New Marketplace Partner Program Partners!

Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...

440 views 5 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you