0

First Question - Is there any way i can verify that the specific jar files or class files has been instrumented using cobertura?

Second Question - Can you please let me know if following ant scipt is fine. I dont get any output from this. nor instrumented file or cobertura.ser and build says ok.

<project>
<property name="cobertura.dir" value="../cobertura-2.0.3" />
<property name="instrumented.dir" value="../destination" />
<property name="jars.dir" value="../basedir" />

<path id="cobertura.classpath">
    <fileset dir="${cobertura.dir}">
        <include name="cobertura-2.0.3.jar" />
        <include name="lib/**/*.jar" />
    </fileset>
</path>



<target name="instrument-classes">
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
<delete file="cobertura.ser" />

<cobertura-instrument todir="${instrumented.dir}">
    <fileset dir="${jars.dir}">
        <include name="XXX.jar" />
    </fileset>
    <fileset dir="${jars.dir}">
        <include name="YYYY.jar" />
    </fileset>
</cobertura-instrument>
</target>
</project>
Rajesh Kumar
  • 355
  • 3
  • 19

1 Answers1

0

You can use a java decompiler to see references to net.sf.cobertura.xxx classes in the instrumented classes. You can also use a simple text editor that accept to visualize binary files (e.g. TextPad) and you will see net.sf.cobertura references as well, if you look carefully (using a text compare tool to compare the original class and the instrumented one makes it more obvious).

Your ant snippet looks all right except possibly for the suspicious:

<property name="jars.dir" value="../basedir" />

Perhaps you meant something like:

<property name="jars.dir" value="${basedir}/.." />

The point is: you should validate that the nested filesets actually include files, otherwise there won't be anything accomplished by the cobertura-instrument task.

Patrice M.
  • 4,209
  • 2
  • 27
  • 36