From: Jeevan C. <cha...@gm...> - 2013-02-20 10:19:47
|
Hi, I had a strange problem while running cobertura code coverage report on one of my ant & junit based java project. The code coverage shows zero for all packages despite the fact the unit tests are running fine. Pasted below are the different tasks added to the ant build xml to get this running: *Classpath:* <path id="cobertura.classpath"> <fileset dir="${cobertura.dir}"> <include name="cobertura.jar" /> <include name="lib/**/*.jar" /> </fileset> </path> <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/> *Instrument:* <property name="instrumented.dir" value="dist/instrumented-classes" /> <target name="instrument" depends="init,compile"> <delete file="cobertura.ser"/> <delete dir="${instrumented.dir}" /> <cobertura-instrument todir="${instrumented.dir}" datafile="cobertura.ser"> <fileset dir="${dist.classes.dir}"> <include name="**/*.class"/> <exclude name="**/*Test*"/> </fileset> </cobertura-instrument> </target> Junit Test: <target name="module-test" depends="module-compile,module-test-postgresql"> <echo level="info" message="Running JUnit test cases..." /> <junit fork="yes" showoutput="yes" printsummary="yes" reloading="false" failureProperty="test.failed"> <jvmarg value="-enableassertions" /> <sysproperty key="net.sourceforge.cobertura.datafile" file="cobertura.ser" /> <classpath location="${instrumented.dir}" /> <classpath location="${dist.classes.dir}" /> <classpath refid="cobertura.classpath" /> <formatter type="xml" /> <batchtest todir="${module.test.dir}"> <fileset refid="test.src.set" /> </batchtest> </junit> </target> *Code coverage:* <target name="code-coverage"> <cobertura-report format="html" srcdir="${examinet.dir}/common/src" destdir="dist/cobertura-report" datafile="cobertura.ser" /> </target> I have the run the following command which went fine but resulting a zero code coverage. *$ ant instrument module-test code-coverage* Please help me with what went wrong with the above configuration that is resulting in a zero code coverage across all packages. Regards, Jeevan |