jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan <gingrichr...@strose.edu>
Subject Re: Possible to use with Cobertura?
Date Wed, 03 May 2006 16:34:46 GMT
Here are snippits of my build.xml.  I have gone over and over it and still
cannot find the reason why Cobertura reports 0% coverage for my servlet tests. 
The tests run ok and the "unit-test-results" are created, but it seems that the
test are not being saved to the cobertura.ser file.  That is my guess at least.
 What am I doing wrong?  Very frustrated, and again, thanks fort he help.


<!-- Setup cobertura instrumented test classes -->
  <target name="code-coverage-setup" depends="compile">
    <delete file="${coberturaDataFile}"/>
    <delete dir="${instDir}"/>
    <mkdir dir="${testingDir}"/>
    <!-- build instrumented class files for code coverage testing -->
    <cobertura-instrument todir="${instDir}" datafile="${coberturaDataFile}">
      <ignore regex="org.apache.log4j.*" />
      <fileset dir="${buildDir}">
        <include name="**/*.class"/>
        <exclude name="**/*Test.class"/>
        <exclude name="**/test/*"/>


  <target name="code-coverage-report">
    <!--Generate a series of HTML files containing the coverage
    data in a user-readable form using nested source filesets.-->
    <cobertura-report datafile="${coberturaDataFile}"
      <fileset dir="${srcJavaDir}">
        <include name="**/*.java"/>
        <exclude name="**/*Test.java"/>
        <exclude name="**/test/*"/>


<!-- Run to setup instrumented class files, run unit tests and generate coverage
  <target name="test" depends="unittest, code-coverage-report"/>

    <!-- unit testing -->
    <target name="unittest" depends="code-coverage-setup">
    <!-- clean the test-results folder -->
    <delete dir="${unitTestResultsDir}"/>
    <!-- create the test-results folder -->
    <mkdir dir="${unitTestResultsDir}/cactus"/>
    <!-- invoke cactus -->
    <cactus warfile="${distDir}/${warName}-cactified.war" 
        Specify the name of the coverage data file to use.
        The value specified below is the default.
      <sysproperty key="net.sourceforge.cobertura.datafile"
        Note the classpath order: instrumented classes are before the
        original (uninstrumented) classes.  This is important.
        <pathelement path="${instDir}"/>
        <pathelement path="${buildDir}"/>
        <pathelement path="${buildDir}/Cactus"/>
        <pathelement path="${cobertura.dir}/cobertura.jar"/>
        The instrumented classes reference classes used by the
        Cobertura runtime, so Cobertura and its dependencies
        must be on your classpath.
      <classpath refid="cobertura.classpath"/>
        <pathelement location="${cobertura.dir}/cobertura.jar"/>
      <!-- set log4j.configuration system property -->
      <jvmarg value="-Dlog4j.configuration=file:${testLoggingProperties}"/>
      <!-- define the classpath 
      <classpath refid="project.class.path"/>-->
      <path refid="project.class.path"/>
      <pathelement location="${cobertura.dir}/cobertura.jar"/>
      <pathelement location="${cactus.dir}/lib/httpunit-1.6.jar"/>
      <pathelement location="${cactus.dir}/lib/nekohtml-0.9.1.jar"/>
      <pathelement location="${thirdPartyLibsDir}"/>
    <!-- define the formatter -->
    <formatter type="brief" usefile="false"/>
    <formatter type="plain"/>
      <tomcat5x if="cactus.home.tomcat5x"
    <!-- setup for batch-testing -->
    <batchtest fork="yes" todir="${unitTestResultsDir}">
      <fileset dir="${buildDir}/Cactus">
		<include name="**/*ServletTest.class"/>

View raw message