cobertura instrumentation context already initialized

59 views Asked by At

I am trying to generate the coverage report for my unit tests through cobertura. Below are the steps I followed 1. Compile my code into a jar 2. Instrument the jar file 3. Run unit tests with the instrumented code

I get the error context already initialized, for all the unit test Instead of the instrumented class files if i use the original jar the unit tests run but I get O% coverage in code.

below is my ant target for junit

<junit reloading="false" fork="yes" forkmode="perBatch" printSummary="yes" failureproperty="test.failure" includeantruntime="yes">
<jvmarg value="-XX:UseSplitVerifier" />
<sysproperty key="net.sourceforge.cobertura.datafile" value="{reports.dir}/cobertura.ser" />

<classpath>
<!-- Jar file of instrumented classes -->
<pathelement location="My_code_inst.jar">
<!-- Tests run with this jar but no coverage data -->
<!--pathelement location="My_code.jar" -->
<pathelement location="My_Test.jar"/>
</classpath>

<classpath refid="junit.classpath" />
<classpath refid="cobertura.classpath" />
<batchtest fork="yes" todir="${reports.dir}">
<resources>
<zipfileset src="My_Test.jar" includes="**/*Test.class"/>
</resources>
</batchtest>
</junit>

I did a binary comparison of My_code_inst.jar and My_code.jar. Did not see any orphans. The disassembled code revealed instrumented methods.

0

There are 0 answers