Odd Cobertura Issue

View: New views
1 Messages — Rating Filter:   Alert me  

Odd Cobertura Issue

by sguillory6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
    I am having an issue where the first time I run my unit tests, the cobertura reports report 0% coverage for everything. Then I immediately run the unit tests again, and the reports are correct. Any idea why this would happen? Here is my classpath and my instrument and test targets:


        <path id="test.runtime.classpath">
            <pathelement location="${build.cobertura-instrumented-classes}"/>
            <pathelement location="${test.build.classes}"/>
            <path refid="cobertura.classpath"/>
            <!--pathelement location="${resources.test}"/-->

            <!-- Include runtime classpath -->
            <!--path refid="runtime.classpath"/-->

            <path refid="dependent.test.classpath"/>
           
            <pathelement location="${junit.jar}"/>
        </path>


    <target name="unittest" depends="build-test,cobertura-instrument">
        <fileset dir="${source.test}" id="test.classes.id.default">
            <include name="**/*Test.java"/>
            <exclude name="**/AllTests.java"/>
        </fileset>

        <mkdir dir="${reports.test}"/>
        <junit printsummary="withOutAndErr" showoutput="true" forkmode="once" haltonfailure="no"
               failureproperty="unit.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="${basedir}/cobertura.ser" />

            <jvmarg value="-javaagent:${aspectjweaver.jar}"/>
            <classpath refid="test.runtime.classpath"/>
            <formatter type="xml"/>
            <test name="${testcase}" todir="${reports.test}" if="testcase"/>
            <batchtest fork="once" todir="${reports.test}" unless="testcase">
                <fileset refid="${test.classes.reference}"/>
            </batchtest>
        </junit>

        <junitreport todir="${reports.test}">
            <fileset dir="${reports.test}">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="${reports.test}/html"/>
        </junitreport>

        <cobertura-report format="html" destdir="${reports.cobertura}" srcdir="${source.home}"
                          datafile="${basedir}/cobertura.ser"/>
    </target>

    <target name="cobertura-instrument" depends="compile">
        <cobertura-instrument todir="${build.cobertura-instrumented-classes}" datafile="${basedir}/cobertura.ser">
            <fileset dir="${build.classes}">
                <include name="**/*.class"/>
            </fileset>
        </cobertura-instrument>
    </target>

Thanks,
Stan
LightInTheBox - Buy quality products at wholesale price