I have tried everything I can think of and even took Bret Kumler's advise in the
earler postings.  The Cactus tests still run fine, the JUnit report reports that
the tests were sucessful, however for some reason, Cobertura is not working. 
Here are parts of my build.xml.  If anyone can see what I am doing wron please
let me know... Not beign able to figure this out is driving me insane!

Ryan



<project name="${projectName}" default="dist" basedir=".">
  <!-- project properties are in build.properties -->
  <property file="build.properties"/>

  <!-- set calculated properties for this build -->
  <property name="srcJavaDir" value="${srcDir}/Java"/>
  <!--added for cactus purposes-->
  <property name="srcCactusDir" value="${srcDir}/Cactus"/>
  <property name="instDir" value="${genDir}/Instrumented"/>

  <!-- location of instrumented Jars for code coverage testing -->
  <property name="testingDir" value="${genDir}/test"/>
  <property name="testingJAR" value="${genDir}/bin/test-${jarName}.jar"/>
  <property name="unitTestResultsDir" value="${genDir}/test/unit-test-results"/>
  <property name="coberturaDataFile" value="${testingDir}/cobertura.ser"/>
  <property name="codeCoverageReportDir"
            value="${testingDir}/code-coverage-report"/>
  
  <!-- Build the Classpath -->
  <path id="project.class.path">
        <fileset dir="${thirdPartyLibsDir}">
      <include name="**/*.jar"/>
    </fileset>
    <fileset dir="${envLibsDir}">
      <include name="**/*.jar"/>
    </fileset>
  </path>
  
  <!--Build the cactus classpath-->
  <path id="cactus.classpath">
        <path refid="project.class.path"/>
        
        <fileset dir="${cactus.dir}">
      <include name="lib/*.jar"/>
    </fileset>
  </path>

  
  
  <!-- Code Coverage lib -->
    <property name="cobertura.lib"
              value="${cobertura.dir}/cobertura.jar" />
    
    <property name="asm.lib"
              value="${cobertura.dir}/lib/asm/asm-2.1.jar"/>
    
    <property name="cov-log4j.lib"
              value="${cobertura.dir}/lib/log4j/1.2.9/log4j-1.2.9.jar" />
    
    <property name="ccl.lib"
              value="${cobertura.dir}/lib/ncss/21.41/ccl.jar"/>
    
    <property name="javancss.lib"
              value="${cobertura.dir}/lib/ncss/21.41/javancss.jar" />
    
    <property name="jakarta-oro.lib"
              value="${cobertura.dir}/lib/oro/jakarta-oro-2.0.8.jar" />


<!-- Setup for Cobertura - code coverage evaluation tool -->
  <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"/>
  
  

  <!-- setup steps required before compilation -->
  <target name="init">
        <taskdef resource="cactus.tasks" classpathref="cactus.classpath"/>
        
        <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${buildDir}"/>
    <mkdir dir="${buildDir}/Cactus"/>
    <mkdir dir="${distDir}"/>
    <mkdir dir="${genDir}/bin"/>
    
  </target>

  <!-- compilation -->
  <target name="compile.java" depends="init">
  <!-- Compile the java code from ${srcJavaDir} into ${buildDir} -->
    <javac srcdir="${srcJavaDir}" destdir="${buildDir}" debug="Yes"
source="${sourceVersion}">
      <classpath refid="project.class.path"/>
    </javac>
  </target>
  
  <target name="compile.cactus" depends="init">
    <!-- Compile the cactus java code from ${srcCactusDir} into ${buildDir} -->
    <javac srcdir="${srcCactusDir}" destdir="${buildDir}/Cactus" debug="Yes"
source="${sourceVersion}">
      <classpath>
        <path refid="cactus.classpath"/>
        <!-- <pathelement location="${httpunit.jar}"/> -->
        <!-- <pathelement location="${nekohtml.jar}"/> -->
        <pathelement location="${buildDir}"/>
      </classpath>
    </javac>
  
  </target>
  
  
  <target name="compile" depends="compile.java, compile.cactus"/>

  <!-- 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 datafile="${coberturaDataFile}" todir="${instDir}">
      <ignore regex="org.apache.log4j.*" />
      <fileset dir="${buildDir}">
        <include name="**/*.class"/>
        <exclude name="**/*Test.class"/>
        <exclude name="**/test/*"/>
      </fileset>
    </cobertura-instrument>  
  </target>
  
  <!-- Package up the test classes and added the test package to the war file 
-->

<target name="prepare.cactus" depends="code-coverage-setup">
<!--<mkdir dir="${test-lib.dir}"/>
        <mkdir dir="${test-war.dir}"/>
        <mkdir dir="${test-props.dir}"/>-->

        <!-- Temporary hack until cobertura bug is fixed -->
        <copy todir="${cactus.home.tomcat5x}/common/lib"
                          file="${cobertura.lib}"/>
                          
        <copy todir="${cactus.home.tomcat5x}/common/lib"
                          file="${asm.lib}"/>
                          
        <copy todir="${cactus.home.tomcat5x}/common/lib"
                          file="${cov-log4j.lib}"/>
                          
        <copy todir="${cactus.home.tomcat5x}/common/lib"
                          file="${ccl.lib}"/>
                          
        <copy todir="${cactus.home.tomcat5x}/common/lib"
                          file="${javancss.lib}"/>
                          
        <copy todir="${cactus.home.tomcat5x}/common/lib"
                          file="${jakarta-oro.lib}"/>
    
   

    <!--<mkdir dir="${dist.dir}/war" />-->

        <war warfile="${distDir}/${warName}.war" webxml="${srcDir}/web.xml"
             manifest="${srcDir}/${manifestForWAR}">
                <classes dir="${instDir}">
                        <include name="**/*.class" />
                </classes>
                <lib dir="${thirdPartyLibsDir}"/>
                <classes dir="${buildDir}">
                        <include name="**/*.class" />
                        <exclude name="**/*Test.class" />
                        <exclude name="**/test/*"/>
                </classes>
                <classes dir="${addlClassesDir}"/>
    </war>
    
    
    

         <!--Cactify the WAR-->
        <cactifywar srcfile="${distDir}/${warName}.war" 
                                destfile="${distDir}/${warName}-cactified.war"
                                mergewebxml="${srcDir}/cactus-web.xml">
                <classes dir="${buildDir}/Cactus"/>
    
                <lib file="${cactus.dir}/lib/httpunit-1.6.jar"/>
                <lib file="${cobertura.dir}/cobertura.jar"/>
                <lib dir="${thirdPartyLibsDir}"/>
    
    
    <servletredirector/>
    <servletredirector name="ServletRedirectorSecure"
                                           mapping="/ServletRedirectorSecure"
                                           roles="test"/>
        </cactifywar>

  </target>

  

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

  <!-- unit testing -->
  <target name="unittest" depends="code-coverage-setup, prepare.cactus">
    <!-- clean the test-results folder -->
    <delete dir="${unitTestResultsDir}"/>
    <!-- create the test-results folder -->
    
    <mkdir dir="${unitTestResultsDir}/cactus"/>
    <delete file="BSSTrainingWebLog.txt"/>

    <!-- invoke cactus -->
    <cactus fork="yes"
            warfile="${distDir}/${warName}-cactified.war"              
            haltonfailure="no" 
            failureproperty="tests.failed">    

        <!--
        Specify the name of the coverage data file to use.
        The value specified below is the default.-->
     
      <sysproperty key="net.sourceforge.cobertura.datafile"
                   file="${coberturaDataFile}"/>
      
      <containerclasspath>
                <pathelement path="${testingJar}"/>
                <pathelement path="cobertura.classpath"/>
                <pathelement path="${srcCactusDir}"/>
      </containerclasspath>
            
      <!--
        Note the classpath order: instrumented classes are before the
        original (uninstrumented) classes.  This is important.
      
      <classpath location="${instDir}"/>
      <classpath location="${buildDir}"/>-->
      <classpath>
        <pathelement location="${instDir}"/>
        <pathelement location="${buildDir}"/>
        <pathelement location="${buildDir}/Cactus"/>
        <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}"/>
        <path refid="project.class.path"/>
    </classpath>
      <!--
        The instrumented classes reference classes used by the
        Cobertura runtime, so Cobertura and its dependencies
        must be on your classpath.-->
      
      <classpath refid="cobertura.classpath"/>
      
      
     
      
      <!-- set log4j.configuration system property -->
      <jvmarg value="-Dlog4j.configuration=file:${testLoggingProperties}"/>
      
      <!-- define the classpath -->
      <classpath refid="project.class.path"/>
     
    <containerset>
      <tomcat5x if="cactus.home.tomcat5x"
        dir="${cactus.home.tomcat5x}"
        port="${cactus.port}"
        output="${testingDir}/cactus.out"
        todir="${unitTestResultsDir}/cactus"
        serverxml="${cactus.home.tomcat5x}/conf/server.xml"/>
       <!-- 
jvmArgs="-Dnet.sourceforge.cobertura.datafile=${coberturaDataFile}"-->
    </containerset>
    
    <!-- define the formatter -->
    <formatter type="brief" usefile="false"/>
    <formatter type="xml"/>
    
    <!-- setup for batch-testing -->
    <batchtest fork="yes" todir="${unitTestResultsDir}">
      <fileset dir="${buildDir}/Cactus">
                <include name="**/*.class"/>
          </fileset>
    </batchtest>   
  </cactus>   
    
    <fail if="tests.failed">
      tests.failed=${tests.failed}
    </fail>
    
    <!-- Generate the JUnit reports -->

        <junitreport todir="${unitTestResultsDir}/cactus">
            <fileset dir="${unitTestResultsDir}/cactus"
                 includes="TEST-*.xml"/>
            <report todir="${unitTestResultsDir}/cactus"
                format="frames"/>
        </junitreport>

    
  </target>
  
  <!-- Generate code coverage report-->
  <target name="code-coverage-report">
    <delete dir="${codeCoverageReportDir}"/>
    <cobertura-report format="html" datafile="${coberturaDataFile}"
destdir="${codeCoverageReportDir}">
      <fileset dir="${srcJavaDir}">
        <include name="**/*.java"/>
        <exclude name="**/*Test.java"/>
        <exclude name="**/test/*"/>
      </fileset>
      
    </cobertura-report>
     
  </target>

  

</project>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to