Search code examples
javacode-coverageemma

How exactly does EMMA mark the covered lines of code..?


With regard to the working of EMMA..would like to know how EMMA marks the lines of code with respect to the source code. And is there a way to extract only the covered/marked lines?


Solution

  • EMMA does an instrumentation of the class files and the instrumentation code (additional byte code) is used to generate the coverage reports.

    It is not working on source files. Of course, the class files need "debug information", especially line numbers. But that's usually the case.

    Update

    It looks like, only the html report generator is capable of matching coverage results to line numbers. I wasn't able to get the same details for text or xml reports.

    For a quick solution, I'd simply create the html reports and parse them with a html parser (xml parser could work as well) and extract the date from the html tables.

    Alternatively, execute emmarun with the -raw option and look at the metadata and coverage files.