ant - Cobertura generates my reports for code coverage, but the coverage shows as 0% -


all of reports generated, coverage shows 0%. created 1 dummy test make sure wasn't way tests written, , doesn't show 1 dummy class i'm covering. here ant build this:

<?xml version="1.0" encoding="utf-8" ?> <project name="my project name" default="run.cobertura" basedir=".">      <description>my description</description>      <!-- target: init -->      <target name="init">          <!-- create properties , directory structure -->          <property name="src.path" value="${basedir}/src" />         <property name="lib.path" value="${basedir}/lib" />         <property name="output.path" value="${basedir}/bin" />         <property name="testcase-unit-only.path" value="${basedir}/testcase-unit-only" />         <property name="testcase-unit-only.output.path" value="${basedir}/test-classes" />          <property name="cobertura.lib.path" value="${basedir}/lib-cobertura" />         <property name="cobertura.path" value="${basedir}/cobertura" />         <property name="cobertura.output.path" value="${cobertura.path}/bin" />         <property name="cobertura.reports.path" value="${cobertura.path}/reports" />         <property name="cobertura.data.file" value="${cobertura.path}/cobertura.ser" />          <delete dir="${testcase-unit-only.output.path}" />         <delete dir="${cobertura.path}"/>          <mkdir dir="${testcase-unit-only.output.path}"/>         <mkdir dir="${cobertura.path}"/>         <mkdir dir="${cobertura.output.path}"/>          <!-- define classpath references -->          <path id="cp.lib.path">             <fileset dir="${lib.path}">                 <include name="*.jar"/>             </fileset>         </path>          <path id="cp.classes.path">             <pathelement path="${output.path}" />         </path>          <path id="cp.classes.test.path">             <pathelement path="${testcase-unit-only.output.path}" />         </path>          <path id="cp.lib.cobertura.path">             <fileset dir="${cobertura.lib.path}">                 <include name="*.jar"/>             </fileset>         </path>          <path id="cp.all.path">             <path refid="cp.lib.path"/>             <path refid="cp.classes.path"/>             <path refid="cp.lib.cobertura.path"/>         </path>      </target>      <!-- target: run.cobertura-instrument -->      <target name="run.cobertura-instrument">          <taskdef classpathref="cp.lib.cobertura.path" resource="tasks.properties"/>          <cobertura-instrument todir="${cobertura.output.path}" datafile="${cobertura.data.file}">             <fileset dir="${output.path}">                 <include name="**/*.class" />             </fileset>         </cobertura-instrument>      </target>      <!-- target: compile.classes -->      <target name="compile.classes">          <javac srcdir="${src.path}" destdir="${output.path}">             <classpath refid="cp.lib.path"/>         </javac>      </target>      <!-- target: compile.tests -->      <target name="compile.tests">          <javac srcdir="${testcase-unit-only.path}" destdir="${testcase-unit-only.output.path}">             <classpath refid="cp.all.path"/>         </javac>      </target>      <!-- target: run.junit -->      <target name="run.junit">          <junit fork="true" dir="${basedir}" failureproperty="test.failed">              <classpath location="${cobertura.output.path}"/>             <classpath location="${output.path}"/>              <sysproperty key="net.sourceforge.cobertura.datafile" file="${cobertura.data.file}" />              <classpath refid="cp.lib.path"/>             <classpath refid="cp.classes.test.path"/>             <classpath refid="cp.lib.cobertura.path"/>              <formatter type="xml" />             <!-- <formatter type="brief" usefile="false"/> -->              <batchtest todir="${testcase-unit-only.output.path}" unless="testcase">                 <fileset dir="${testcase-unit-only.output.path}">                     <include name="**/*unittest.java"/>                 </fileset>             </batchtest>          </junit>      </target>      <!-- target: run.cobertura -->      <target name="run.cobertura" depends="init,run.cobertura-instrument,compile.classes,compile.tests,run.junit">          <cobertura-report srcdir="src" destdir="${cobertura.reports.path}" datafile="${cobertura.data.file}"/>      </target>  </project> 

one thing notice in depends list run.cobertura target instrument compiled classes before compile them. might work if run twice, assuming compiled classes first run not cleared down, doesn't seem quite right. on first run if there no instrumented classes, report empty.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -