JavaCodeCoverage: A Java Code Coverage Analyzer Tool
Requirements: Download
Operating System: Linux
Packages Required: BCEL (bcel.jar may be downloaded from http://jakarta.apache.org/bcel/ )
Database: MySQL (included in LINUX versions)
How to install the tool:
Unzip the javacodecoverage.zip and do the following steps:
1. Include JavaCover.jar and bcel.jar files in your CLASSPATH. This is done by following command
$export CLASSPATH=<location of JavaCover.jar>:$CLASSPATH
alternately, you can edit the etc/environment file by
$sudo gedit /etc/environment
and update the CLASSPATH variable
If you have problem in class version try making it from source code:
Making JavaCover.jar from Source:
goto Source code folder and run
$sh make.sh
JavaCover.jar is created in source code folder.
2. Configure the database
start mysql server if it not already running
service mysqld start
Create database for particular project
$su //not required if you have mysql administrative access, else
$mysql -u root -p
$create database <database name>
$grant all on <database name>.* to <user>@localhost identified by '<password>'
If multiple people want to you use same project grant permissions for individual user using the above command.
3. Edit Setting.properties file to refelect the <database name>, <user>, and the <password>
change local host to your server name if you are using database on the network.
provide username and password for mysql access. If you are using other database change
driver field appropriately.
4. run $./setUp
// This will Initialize database for the project.
// If the project already consist it is deleted and fresh project is created.
5. Perform Testing
Compile the source code (*.java files)
Modifying the run.bat file to include the intended .class files for instrumentation (byte code instrumentation)
run $./run.bat
6. Using the Coverage tool for viewing coverage
Invoking GUI:
run $./gui
OR
*** double click JavaCover.jar. Make sure Settings.properties and JavaCover.jar are in same folder
and mysql database is configured.
OR
*** excute $java JavaCover.GUI.GUIDisplay
OR
$java -jar JavaCover.jar
Make sure JavaCover.jar in CLASSPATH and Settings.properties is in current directory.
Instrumenting:
Instrumentation can be done from GUI or from command prompt.
Instrumenting from command prompt
$java JavaCover.Instrument.Instrument <instrumentation options> <class-files>
$java JavaCover.Instrument.InstrumentPackage <original-jar file> <instrumented-jar file>
The ./run batch file included in the zip folder contains an example for instrument and a command for running the code for coverage testing.
Instrumented programs run as normal. You can see as the Java code runs, the coverage is updated dynamically and can be seen through the tool's GUI
NOTE: set CLASSPATH to JavaCover.jar and bcel.jar library, set properties in
Settings.properties and include it in from where you are running java programs.
Please send your comments and suggestions to raghul@gmail.com (Raghu Lingampally) or
atulkg@gmail.com (Atul Gupta)