Measuring code coverage with EMMA
This page is intended to contain up to date information on how to measure code coverage for the Derby tests with the EMMA tool.
Versions
Running the Derby junit tests instrumented with EMMA has been tested with EMMA version 2.0.5312.
Running EMMA with ant
Ant targets have been created to help measure code coverage with EMMA for the Derby tests written in junit. To use these ant targets you need to download EMMA and place the two jar-files (emma.jar and emma_ant.jar) in the tools/java/ directory in your sandbox. Here they will be found by the Derby build system and the ant targets related to EMMA should work as intended. You can download the latest EMMA jar-files from http://emma.sourceforge.net/downloads.html. You should also download junit.jar and put it at the same place, if you are using ant 1.7 the buildsystem will find it there.
The ant targets use your compiled jars (either sane or insane depending on your properties) and instrument these with EMMA code. If you want the code coverage report to contain source code information, you have to compile Derby with debug=true. The Derby jars have to be built with the buildjars
target before using the EMMA targets. The instrumented jars are placed in a separate directory under jars/emma/ and are used to execute the junit tests. The instrumentation process also produces a file named coverage.em with data that EMMA later needs to produce the coverage report, this file is placed in the same directory as the logs from the test.
During the testruns, data on coverage is written to a file named coverage.ec, also located in the directory with the test logs. After the tests are finished, reports are produced using the data located in the coverage.em and coverage.ec files and linked to your source code (if you compiled with debug=true). The reports are named coverage.txt, coverage.xml and coverage.html, and all contain the same information.
Note
EMMA marks a block as covered, only if that block exits normally. Thus if a block terminates due to a thrown exception, it is not marked as covered. http://emma.sourceforge.net/faq.html#q.blockcoverage. So, although coverage report indicates a block of code as uncovered, it might have been invoked.
Ant Targets
ant target |
Comments |
|
Instruments the Derby jar files with EMMA and runs |
|
Instruments the Derby jar files with EMMA and runs |
|
Remove the EMMA-instrumented jar files located at jars/emma/ |
|
Remove any folders from previous junit runs (with or without EMMA) through ant targets. |
Community measurements
Code coverage numbers and reports produced by community members can be found here: CodeCoverage