Emma and Netbeans
As of April 2010, Emma Code Coverage is available as a plugin for
NetBeans.
Code Coverage Plugin
To install plugin, select Tools > Plugins and choose “Code Coverage” in the
list of available plugins.
To activate plugin, right click on Hangman in Projects view and click on
Coverage > Activate Coverage Collection.
Run a JUnit test.
Inspect the source code. Fully covered statements are highlighted in green.
(Note: If you also have the Checkstyle plugin installed, checkstyle errors
will hide the coverage highlighting. So fix the checkstyle errors and then
you can see the coverage highlights.)
To view a report of coverage for the entire project, right click on Hangman
in Projects view and click on Coverage > Show Project Coverage
Statistics.
Most of the remainder of this HOWTO is now OBSOLETE.
It might only be useful if you want to generate HTML
coverage reports outside of the NetBeans IDE.
It's possible to get Emma coverage of your Netbeans web app.
Here's my brief notes:
Put emma.jar in lib
folder of the NetBeans project.
Modify project.properties
- Insert a new file reference:
file.reference.emma.jar=lib/emma.jar
- Add to javac.classpath
property
${file.reference.emma.jar}
Compile the source files.
At the command line, do the emma instrumentation step:
Change directory to the build subfolder containing the class files.
java -cp
pathtolibfolder/emma.jar:.
emma instr -ip . -m overwrite
Run unit tests -- "Test Project". Don't recompile/rebuild the project.
At the command line, run the emma reporting step.
Change directory to the build subfolder containing the class files.
java -cp pathtolibfolder/emma.jar
emma report -r html -sp .
-in coverage.em -in pathtoproject/coverage.ec
The output is in the coverage
folder.
Ultimately, emma can be included as an Ant task in the NetBeans build
script.
That would eliminate the need for the manual command steps.
Whiteboard photo of diagram for
using Emma to get coverage of JSP's.
Other related links:
http://www.cs.uga.edu/~janik/2005-Spring/6050/08-Apr13/Emma-quickHowTo.txt
http://stackoverflow.com/questions/2317679/how-to-change-ant-script-with-emma-code-coverage-so-it-can-find-runtime-coverage