Not to able to get Source file info in Jacoco Coverage Report.

46 views
Skip to first unread message

divyansh agrawal

unread,
Jun 29, 2019, 1:21:02 PM6/29/19
to JaCoCo and EclEmma Users
I am not able to get Source file information while generating the report of Jacoco code Coverage.I even tried  debug="on" while compiling the file and in the tag <sourcefile>  and <classfile > i mentioned  the correct path of source directory of java and class file respectively But then also it is showing me the same error.Can someday help me to rectify this error? Here is my code.

<target name="jacocoTests" depends="buildServerTests" description="run tests with cobertura" >
     <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
             <classpath path="lib/jacocoant.jar"/>
         </taskdef>
        <jacocoTestsParameterized targetClassDir="${SELECTED_TEST_CLASS_DIRECTORY}" classFilterInclude="${SELECTED_TEST_CLASS_NAME}" classFilterExclude="${SELECTED_TEST_CLASS_EXCLUDE_NAME}" />
    </target>
<macrodef name="jacocoTestsParameterized" description="execute Jacoco with parameters" >
<attribute name="targetClassDir" default="ServerTests" description="directory of classes for junit execution" />
        <attribute name="classFilterInclude" default="**/*" description="class filter for include" />
        <attribute name="classFilterExclude" default="**/*$*class" description="class filter for exclude" />
<sequential>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
              <classpath path="lib/jacocoant.jar"/>
            </taskdef>
<jacoco:instrument destdir="${result.classes.instr.dir}/${SELECTED_TEST_CLASS_DIRECTORY}">
              <fileset dir="${SELECTED_TEST_CLASS_DIRECTORY}">
               <filename regex=".class"/>
              </fileset>
            </jacoco:instrument>
<path id="classpath">
              <pathelement location="lib/junit-4.12.jar" />
  <pathelement location="lib/hamcrest-core-1.3.jar" />
  <pathelement location="lib/ant-junit4.jar"/>
   <pathelement location="./${SELECTED_TEST_CLASS_DIRECTORY}/build/manual/classes"/>
   <fileset dir="./lib">
                 <include name="**/*.jar" />
               </fileset>
            </path>
<property name="junitReports" value="target/reports"/>
        <mkdir dir="${junitReports}"/>
<echo message="hello"/>
<delete dir="./target/reports"/>
<delete dir="./target/site/jacoco"/>
<mkdir dir="./target/reports"/>
<mkdir dir="./target/site/jacoco"/>
           <jacoco:coverage destfile="${result.exec.file}">
           <junit haltonfailure="false" showoutput="true" printsummary="yes" fork="true" forkmode="once">
   <formatter type="xml"/>
<classpath refid="classpath"/>
<classpath refid="defaultTESTpath"/>
<classpath location="./ServerTests/build/manual/classes"/>
              <test name="com.hp.ssmc.pianoui.RemoteCopy.VerifyTest" todir="${testreport.dir}"/> 
            </junit>
            </jacoco:coverage>
<junitreport todir="${testreport.dir}">
            <fileset dir="${testreport.dir}">
                <include name="TEST-*.xml" />
            </fileset>
            <report todir="${testreport.dir}"/>
        </junitreport>
<jacoco:report>
        <executiondata>
            <fileset file="${result.exec.file}" />
        </executiondata>

        <structure name="com.hp.ssmc.pianoui.RemoteCopy.VerifyTest">
            <classfiles>
                <fileset dir="${SELECTED_TEST_CLASS_DIRECTORY}/build/manual/classes">
  <include name="**/*.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
               <fileset dir="./ServerTests/manual">
    <include name="**/*.java"/>
</fileset>
            </sourcefiles>
        </structure>

        <html destdir="${result.report.dir}/report.html"/>
<csv destfile="${result.report.dir}/report.csv"/>
<xml destfile="${result.report.dir}/report.xml"/>
    </jacoco:report>
</sequential>
</macrodef>

 

Marc Hoffmann

unread,
Jul 1, 2019, 7:30:00 AM7/1/19
to jac...@googlegroups.com
Does your generated report show a column “Lines” like this report?


If not there is no debug information in your class files.

If there is line counters in the tables double check the source location. If the source fileset is at ./ServerTests/manual this means your sources must be in directory

  ./ServerTests/manual/com/hp/ssmc/pianoui/..

Regards,
-marc





--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/937bded7-ee7b-4966-b7a9-c877710b30b9%40googlegroups.com.

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages