views:

986

answers:

3

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]

+3  A: 

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>
Phill Sacre
+1  A: 

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.
Ken Gentle
A: 

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}"> < 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.

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.
Phill Sacre