Here is my build xml. After I run the target "coverage-test", in command line it displays that the test is passed. Then "cobertura.reports" target is run. But coverage tool report displays no test coverage. What should i do to solve the problem. Can any one explain how to properly configure testNG and Cobertura, in Ant target ?
<project basedir=".">
<property name="src.dir" value="${basedir}/src"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="build" value="${basedir}/build"/>
<property name="tng.conf.dir" value="${src.dir}/conf"/>
<property name="cobertura.dir" value="${lib.dir}/cobertura" />
<property name="coverage-output" value="${basedir}/coverage-output" />
<property name="reports" value="${basedir}/reports" />
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath>
<pathelement location="lib/testng-6.8.jar"/>
</classpath>
</taskdef>
<path id="class_path">
<pathelement path="${build}"/>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="cobertura.classpath">
<fileset dir="${cobertura.dir}">
<include name="cobertura-1.9.4.1.jar" />
<include name="log4j-1.2.17.jar"/>
<include name="asm-3.1.jar"/>
<include name="asm-tree-3.0.jar"/>
<include name="jakarta-oro.jar"/>
<include name="lib/**/*.jar"/></fileset>
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
<!--<cobertura-instrument todir="${instrumented.dir}">-->
<!--<ignore regex="org.apache.log4j.*" />-->
<!--<fileset dir="${build}">-->
<!--<include name="**/*.class" />-->
<!--<exclude name="**/*Test.class" />-->
<!--</fileset>-->
<!--</cobertura-instrument>-->
<target name="clean" description="Clear previous build class files">
<delete dir="${build}" quiet="true"></delete>
<delete file="cobertura.ser" />
<delete dir="${coverage-output}" quiet="true"></delete>
<delete dir="${reports}" quiet="true"></delete>
<!--<delete dir="${coverage-output}/" />-->
</target>
<target name="compile" description="compile java class">
<mkdir dir="${build}"/>
<mkdir dir="${coverage-output}"/>
<mkdir dir="${reports}"/>
<javac srcdir="${src.dir}" destdir="${build}" debug="yes">
<classpath refid="class_path"></classpath>
</javac>
<copy todir="${build}">
<fileset dir="${src.dir}">
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</fileset>
</copy>
</target>
<!--<target name="ng-test" description="Check very specific test ng target only">-->
<!--<testng classpathref="class_path" groups="test-fl-one">-->
<!--<classfileset dir="${build}" includes="**/*Test.class"></classfileset>-->
<!--</testng>-->
<!--</target>-->
<!---->
<!--<target name="test-by-xml" description="Check by Testng xml" depends="cobertura" >-->
<!--<testng classpathref="class_path" outputdir="${build}" haltonfailure="false">-->
<!--<classpath location="${build}"></classpath>-->
<!--<xmlfileset dir="${tng.conf.dir}" includes="testng.xml"/>-->
<!--</testng>-->
<!--</target>-->
<target name="cobertura" depends="compile">
<cobertura-instrument todir="${coverage-output}">
<fileset dir="${build}">
<include name="**/*.class" />
<!--<exclude name="test/*.class"/>-->
</fileset>
</cobertura-instrument>
</target>
<target name="coverage-test" depends="cobertura">
<testng classpathref="class_path" groups="test-fl-one">
<classfileset dir="${coverage-output}" includes="test/*.class" />
</testng>
</target>
<target name="cobertura.reports">
<cobertura-report format="html" srcdir="${build}" destdir="${reports}" />
</target>
</project>
Aucun commentaire:
Enregistrer un commentaire