jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bret Kumler" <bkum...@goldengate.com>
Subject RE: Possible to use with Cobertura?
Date Wed, 03 May 2006 16:53:28 GMT
You need to add the instrumented classes to the war file.

I create a war file with the instrumented classes in it, then cactify
the war file. This is the sample below.

<war destfile="${test-war.dir}/test.war"
            <classes dir="${instrumented.classes}"/>
            <lib dir="${web-build-libs.dir}" />
            <zipfileset dir="${web-build.dir}">
                <exclude name="pages/**"/>
                <exclude name="WEB-INF/**"/>
            <zipfileset dir="${web-build.dir}/pages" prefix="pages"/>
            <zipfileset dir="${web-build-meta.dir}" prefix="WEB-INF">
                <exclude name="classes/**"/>
                <exclude name="lib/**"/>
            <zipfileset dir="${web-build-classes.dir}">
                <exclude name="com/**"/>

 <cactifywar srcfile="${test-war.dir}/test.war"
             <lib file="${thirdparty.dir}/${strutstest.lib}"/>
            <fileset dir="${meta.dir}/${configtype}/test"
excludes="cactus-web.xml" />

The other thing is you are calling the reporting task before the test is
run.  <target name="test" depends="unittest, code-coverage-report"/>

You need to move the code-coverage-report depend out of this target.

It should be 

<target name="code-coverage-report" depends="test"/>
<target name="test" depends="unittest"/>

And u should call "code-coverage-report" target 1st.

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Ryan
Sent: Wednesday, May 03, 2006 9:35 AM
To: cactus-user@jakarta.apache.org
Subject: Re: Possible to use with Cobertura?

Here are snippits of my build.xml.  I have gone over and over it and
cannot find the reason why Cobertura reports 0% coverage for my servlet
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
 What am I doing wrong?  Very frustrated, and again, thanks fort he


<!-- 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}"
      <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
  <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 -->
      <!-- 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"/>

To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-user-help@jakarta.apache.org

This e-mail message and any attachments may contain private, confidential, proprietary or
privileged material of GoldenGate Software, Inc. that is for the sole use of the intended
recipient(s) of this e-mail message.  Any review, copying or distribution or other use of
this e-mail message or any attachments hereto by anyone other than the intended recipient(s)
is strictly prohibited.  If you are not the intended recipient(s) of this e-mail message,
please contact GoldenGate Software, Inc. (415-777-0200) immediately and permanently delete
the original e-mail message and any copies of this e-mail message and all attachments, if

View raw message