After Instrumenting ... next step?

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

After Instrumenting ... next step?

by Report-err :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

After I instrument my class files I get the instrumented classes and the Cobertura.ser file generated in my dist directory (I use JBOSS 4.0 as my server). Next I proceed to do Junit testing. and then generate the cobertura report. All this  goes on fine, but I end up with 0 % coverage! Why does this happen ? my Build.xml is as follows:

<!--  <taskdef classpath="C:/cobertura-1.9/cobertura.jar" resource="tasks.properties" /> -->
        <property name="cobertura.dir" value="C:/cobertura-1.9" />
        <path id="cobertura.classpath">
                <fileset dir="${cobertura.dir}">
                        <include name="cobertura.jar" />
                        <include name="**/*.jar" />
                </fileset>
        </path>

        <taskdef classpathref="cobertura.classpath" resource="tasks.properties" />


        <!-- - - - - - - - - - - - - - - - - -
                target: instrument                  
                - - - - - - - - - - - - - - - - - -->

        <target name="instrument" depends="init,compile.classes" description=" --> Instrument compiled classes for code coverage and create jar">

                <echo>--------------------------------------------------</echo>
                <echo>Executing the **instrument** target</echo>
                <echo>--------------------------------------------------</echo>

                <delete file="${cobertura.ser}" />
                <cobertura-instrument todir="${instrumented.dir}" datafile="${cobertura.ser}/">
                        <ignore regex="org.apache.log4j.*" />
                        <fileset dir="${build.dir}">
                                <include name="com/logistics/ucl/**/*.class" />
                                <include name="com/websina/**/*.class" />
                                <exclude name="**/ClientTest.class" />
                        </fileset>
                </cobertura-instrument>

        </target>
       
        <!-- - - - - - - - - - - - - - - - - -
                target: test                  
                - - - - - - - - - - - - - - - - - -->

        <target name="test" depends="init,compile.classes,instrument">

                <echo>--------------------------------------------------</echo>
                <echo>Executing the **test** target</echo>
                <echo>--------------------------------------------------</echo>

                <junit forkmode="once" fork="true" dir="./" failureproperty="test.failed" printSummary="yes" haltonerror="true">

                        <sysproperty key="net.sourceforge.cobertura.datafile" file="${cobertura.ser}" />

                        <classpath location="${instrumented.dir}" />
                        <classpath refid="cobertura.classpath" />
                        <classpath location="${build.dir}" />

                        <classpath>
                                <fileset dir="${workspace}/web/WEB-INF/lib">
                                        <include name="*.jar" />
                                </fileset>

                                <pathelement path="${instrumented.dir}" />
                                <pathelement path="${build.dir}" />
                        </classpath>

                        <formatter type="xml" />

                        <test name="${build.dir}/com/logistics/ucl/qa" todir="${workspace}/testoutdir" if="testcase" />
                        <batchtest todir="${workspace}/testoutdir">
                                <fileset dir="${source.root}">
                                        <include name="./ClientTest.java" />
                                </fileset>
                        </batchtest>

                </junit>

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

        </target>

        <!-- - - - - - - - - - - - - - - - - -
                                target: coverage-report                  
                                - - - - - - - - - - - - - - - - - -->

        <target name="coverage-report" depends="init,compile.classes,test">

                <echo>--------------------------------------------------</echo>
                <echo>Executing the **coverage-report** target</echo>
                <echo>--------------------------------------------------</echo>

                <cobertura-report format="html" datafile="${cobertura.ser}" srcdir="${source.root}" destdir="${workspace}/CoberturaCoverageReport">
                        <fileset dir="${workspace}">
                                <include name="**/*.java" />
                                <exclude name="**/*Test.java" />
                        </fileset>
                </cobertura-report>
        </target>

        <!-- - - - - - - - - - - - - - - - - - - - - -
                                target: Cobertura-Coverage-Report                  
                                - - - - - - - - - - - - - - - - - - - - -->

        <target name="Cobertura-Coverage-Report" depends="init,compile.classes,instrument,test,coverage-report" />


Please advice whether Cobertura.ser needs to be copied to any other directory. Do I need to stop the server to run the 'test' target?

Report-err

Re: After Instrumenting ... next step?

by John W. Lewis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Ah.   This is a client/server scenario.   You need to make sure the instrumented classes are loaded by JBoss.   So, this would typically involve copying the instrumented jars into the webapp directory under the JBoss installation.

You can also instrument a war or ear file.   Sometimes that is more convenient than working with class files.

John

-----Original Message-----
From: cobertura-devel-bounces@... [mailto:cobertura-devel-bounces@...] On Behalf Of Report-err
Sent: Tuesday, April 29, 2008 2:13 AM
To: cobertura-devel@...
Subject: [Cobertura-devel] After Instrumenting ... next step?


Hi

After I instrument my class files I get the instrumented classes and the
Cobertura.ser file generated in my dist directory (I use JBOSS 4.0 as my
server). Next I proceed to do Junit testing. and then generate the cobertura
report. All this  goes on fine, but I end up with 0 % coverage! Why does
this happen ? my Build.xml is as follows:

<!--  <taskdef classpath="C:/cobertura-1.9/cobertura.jar"
resource="tasks.properties" /> -->
        <property name="cobertura.dir" value="C:/cobertura-1.9" />
        <path id="cobertura.classpath">
                <fileset dir="${cobertura.dir}">
                        <include name="cobertura.jar" />
                        <include name="**/*.jar" />
                </fileset>
        </path>

        <taskdef classpathref="cobertura.classpath" resource="tasks.properties" />


        <!-- - - - - - - - - - - - - - - - - -
                target: instrument
                - - - - - - - - - - - - - - - - - -->

        <target name="instrument" depends="init,compile.classes" description=" -->
Instrument compiled classes for code coverage and create jar">

                <echo>--------------------------------------------------</echo>
                <echo>Executing the **instrument** target</echo>
                <echo>--------------------------------------------------</echo>

                <delete file="${cobertura.ser}" />
                <cobertura-instrument todir="${instrumented.dir}"
datafile="${cobertura.ser}/">
                        <ignore regex="org.apache.log4j.*" />
                        <fileset dir="${build.dir}">
                                <include name="com/logistics/ucl/**/*.class" />
                                <include name="com/websina/**/*.class" />
                                <exclude name="**/ClientTest.class" />
                        </fileset>
                </cobertura-instrument>

        </target>

        <!-- - - - - - - - - - - - - - - - - -
                target: test
                - - - - - - - - - - - - - - - - - -->

        <target name="test" depends="init,compile.classes,instrument">

                <echo>--------------------------------------------------</echo>
                <echo>Executing the **test** target</echo>
                <echo>--------------------------------------------------</echo>

                <junit forkmode="once" fork="true" dir="./" failureproperty="test.failed"
printSummary="yes" haltonerror="true">

                        <sysproperty key="net.sourceforge.cobertura.datafile"
file="${cobertura.ser}" />

                        <classpath location="${instrumented.dir}" />
                        <classpath refid="cobertura.classpath" />
                        <classpath location="${build.dir}" />

                        <classpath>
                                <fileset dir="${workspace}/web/WEB-INF/lib">
                                        <include name="*.jar" />
                                </fileset>

                                <pathelement path="${instrumented.dir}" />
                                <pathelement path="${build.dir}" />
                        </classpath>

                        <formatter type="xml" />

                        <test name="${build.dir}/com/logistics/ucl/qa"
todir="${workspace}/testoutdir" if="testcase" />
                        <batchtest todir="${workspace}/testoutdir">
                                <fileset dir="${source.root}">
                                        <include name="./ClientTest.java" />
                                </fileset>
                        </batchtest>

                </junit>

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

        </target>

        <!-- - - - - - - - - - - - - - - - - -
                                target: coverage-report
                                - - - - - - - - - - - - - - - - - -->

        <target name="coverage-report" depends="init,compile.classes,test">

                <echo>--------------------------------------------------</echo>
                <echo>Executing the **coverage-report** target</echo>
                <echo>--------------------------------------------------</echo>

                <cobertura-report format="html" datafile="${cobertura.ser}"
srcdir="${source.root}" destdir="${workspace}/CoberturaCoverageReport">
                        <fileset dir="${workspace}">
                                <include name="**/*.java" />
                                <exclude name="**/*Test.java" />
                        </fileset>
                </cobertura-report>
        </target>

        <!-- - - - - - - - - - - - - - - - - - - - - -
                                target: Cobertura-Coverage-Report
                                - - - - - - - - - - - - - - - - - - - - -->

        <target name="Cobertura-Coverage-Report"
depends="init,compile.classes,instrument,test,coverage-report" />


Please advice whether Cobertura.ser needs to be copied to any other
directory. Do I need to stop the server to run the 'test' target?


-----

Report-err
--
View this message in context: http://www.nabble.com/After-Instrumenting-...-next-step--tp16953696p16953696.html
Sent from the cobertura-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Cobertura-devel mailing list
Cobertura-devel@...
https://lists.sourceforge.net/lists/listinfo/cobertura-devel

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Cobertura-devel mailing list
Cobertura-devel@...
https://lists.sourceforge.net/lists/listinfo/cobertura-devel
LightInTheBox - Buy quality products at wholesale price!