Search code examples
reportcode-coverageemma

emma code coverage report


I have a maven project which follows common core web package.

I want to run Emma tool for code coverage. The requirement is I want to run emma code coverage tool to my maven based project and generate a report.

I am completely new to this tool and trying out the commands as specified in internet. As I don't have any main method in my maven project(we get the ear and deploy in jboss), I had to create a pojo file to invoke a service and build the pojo jar by including the maven project jars.

Now I have only emma.jar in my system, a jar containing the main method and the maven project jars. As I want in report based format from the tool, I run the emma tool from batch command(in the location where emma.jar is present) -> java emmarun -jar <jar containing the main method>

I get the report as

[EMMA v2.0.5312 report, generated Thu Mar 29 20:36:04 IST 2012]
OVERALL COVERAGE SUMMARY:

[class, %]  [method, %] [block, %]  [line, %]   [name] 
100% (5/5)  79%  (11/14)    77%  (266/344)! 76%  (60/79)!   all classes

OVERALL STATS SUMMARY:

total packages: 1 total classes:    5 total methods:    14 total executable files:  4 total executable lines:   79

COVERAGE BREAKDOWN BY PACKAGE:

[class, %]    [method, %]      [block, %]      [line, %]    [name] 100% (5/5)
79%  (11/14)  77%  (266/344)!  76%  (60/79)!   org.eclipse.jdt.internal.jarinjarloader
-------------------------------------------------------------------------------

But from here I don't understand which are the class files that are covered during method invocation from the pojo file bundled in the jar.

I am not sure about my approach or is there any other step I am missing to get the report?


is there any ref links to unit tests..how can I code a simple unit test...the usage steps was quite confusing.So I thot of any simple step to test the maven project using command prompt for code coverage...else is there any other tool other then emma which can simplify my approach...I want to use some code coverage tool to test a maven project from command prompt..this is my main requirement


Solution

  • Please read this QuickStartGuide.

    You have to provide the source code and create an html report, to view complete statistics.

    Example:

    java -cp emma.jar emmarun -r html -jar the_jar -sp path_to_source