EMMA coverage tool not displaying line-by-line coverage
Asked Answered
I

4

5

I am using the EMMA tool for code coverage yet despite my best efforts, EMMA is refusing to see the original .java files and generate coverage on a line-by-line basis.

We are using ANT to build the code and debug is set to true. I know that EMMA is measuring coverage as the .emma files seem to be generating and merging correctly. The reports are able to present high level method coverage with percentages.

But why won't it see the .java files? All I get is: [source file 'a/b/c/d/e/f/code.java' not found in sourcepath]

Inductor answered 31/10, 2008 at 15:56 Comment(1)
Could you post your ANT file or the portion of it where you generate the EMMA reports? My guess is that there is an error in the 'report sourcepath'Rightward
H
6

Are you setting the sourcepath in your report element?

<report>
    <sourcepath>
        <pathelement path="${java.src.dir}" />
    </sourcepath>
    <fileset dir="data">
        <include name="*.emma" />
    </fileset>

    <txt outfile="coverage.txt" />
    <html outfile="coverage.html" />
</report>
Hydrotropism answered 31/10, 2008 at 16:7 Comment(1)
Phill, I am facing same with maven:(Iyar
R
2

Could you post the portion of your build.xml that generates the EMMA reports? Sounds like a report sourcepath issue.

report sourcepath should point to your java source.

See sourcepath in the EMMA reference. This can be a path-like structure, so you can include multiple source directories.

As always, with ANT:

  • execute the smallest possible build.xml with -verbose
  • -debug for even more information.
Rightward answered 31/10, 2008 at 16:15 Comment(0)
M
1

I ran into the same issue. But found that while setting the sourcepath we need to set to the only directory level not to the java file location. it is similar to the classpath

Mcgill answered 3/5, 2012 at 2:36 Comment(0)
I
0

does {java.src.dir} need to point to one specific src directory.

This is no one single src directory as I am compiling multiple projects. Each with their own build.xml file.

I believe this is the portion that generates all the coverage reports:

  <target name="emma.report" if="use.emma">
   <emma enabled="true">
     <report sourcepath="${test.reports.dir}">
       <!--  collect all EMMA data dumps (metadata and runtime):   --> 
       <infileset dir="${test.data.dir}" includes="*.emma" /> 
       <html outfile="${test.reports.dir}/coverage.html" /> 
     </report>
   </emma>
 </target>

EDIT: I changed the sourcepath to point directly to one of the src directories. See if that works.

Inductor answered 31/10, 2008 at 16:22 Comment(1)
As I understand it, your source path needs to point to all your source directories, otherwise it won't be able to find the .java files.Hydrotropism

© 2022 - 2024 — McMap. All rights reserved.