EMMA Code Coverage has problem with Groovy classes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

EMMA Code Coverage has problem with Groovy classes

Steven Harris-5
Hi All,
 
Has anybody been able to get EMMA to run on Groovy code.
 
From what I have heard, at the end of the day, a .class file from groovyc is the same as any other Java class file.
However, when I instrument my groovy class files using EMMA and then attempt to generate a report I get the following:
 
   [report] processing input files ...
   [report] 1 file(s) read and merged in 0 ms
   [report] nothing to do: no runtime coverage data found in any of the data files
 
This is caused by the fact that when running the unit test, EMMA complains that the class file does not have "full debug info":
 
emma:
    [mkdir] Created dir: e:\Emma-Groovy-Test\target\outinstr
    [instr] processing instrumentation path ...
   
[instr] package [emmatest] contains classes [MathOp] without full debug info
    [instr] instrumentation path processed in 124 ms
    [instr] [2 class(es) instrumented, 0 resource(s) copied]
    [instr] metadata merged into [e:\Emma-Groovy-Test\target\metadata.emma] {in 16 ms}
 
It seems that when EMMA hits a file without full debug info it will simply stop dead in it's tracks. This is corroborated by an EMMA FAQ entry as follows:
 

3.9. Why does EMMA's HTML report refuse to link to my sources if some of my classes were compiled without full debug info?

^

In order to properly map bytecode to your Java sources, the report generator needs some of the information that is added by javac when its -g option is used (in ANT, it would be the debug='true' attribute of <javac> task).

Even if the generator were allowed to skip linking for the offending classes, it also needs to compute aggregate line coverage percentages for the rest of the report. Without knowing line coverage for all classes in the instrumentation set there is no way to roll up such statistics.

I get this behavior despite that fact that I do have debugging turned on in my ant build.xml file as follows:

    <target name="compile">
        <mkdir dir="${build.home}/classes"/>
        <groovyc srcdir="src"
                 destdir="${build.home}/classes">
                    <classpath>
                        <pathelement location="**/*.classes"/>
                        <pathelement location="lib/groovy-all-1.5.6.jar"/>
                    </classpath>
                    <javac source="src" target="${build.home}"
                           debug="true" debuglevel="lines,source"/>
                </groovyc>
    </target>

Has anybody been able to produce a code coverage report using EMMA on Groovy code??

Any help is greatly appreciated.

I have included the Groovy files that I am using (very trivial) below.

Many Thanks,

Steven Harris

PS: When I run the code from IDEA (not using my ant file at all) and I set the test run up to collect code coverage results I get the exact same error message from IDEA. When I try to "analyze" the code coverage results it tells me there is no code coverage, yet the test runs successfully.


package emmatest

class MathOp {

    int add(int i1, int i2) {
        return i1 + i2;
    }

}

package emmatest;

class TestMathOp extends GroovyTestCase {

    void testAdd() {
        MathOp mop = new MathOp()
        int result = mop.add(2, 3)
        println result
        assertEquals(5, result)
    }
}

 

Reply | Threaded
Open this post in threaded view
|

Re: EMMA Code Coverage has problem with Groovy classes

amasha
This post has NOT been accepted by the mailing list yet.
I meet the same problem, can you tell me how to solve it?

gen-report-coverage:
   [report] processing input files ...
   [report] 1 file(s) read and merged in 16 ms
   [report] nothing to do: no runtime coverage data found in any of the data files

Script can cretate a metadata.ema file in target file, but nothing to do: no runtime coverage data found in any of the data files.
Reply | Threaded
Open this post in threaded view
|

Re: EMMA Code Coverage has problem with Groovy classes

amasha
This post has NOT been accepted by the mailing list yet.
I meet the same problem, can you tell me how to solve it?

gen-report-coverage:
   [report] processing input files ...
   [report] 1 file(s) read and merged in 16 ms
   [report] nothing to do: no runtime coverage data found in any of the data files

Script can cretate a metadata.ema file in target file, but nothing to do: no runtime coverage data found in any of the data files.