Enabling statically instrumented code coverage from the command line
You can enable static instrumentation of your code from
a command line.
About this task
You can only instrument code from a command line if you are working on the same computer where the you installed the product.
To statically instrument your code from a command line:- Configure your CLASSPATH to enable code coverage.
- Run the code coverage instrumentation script .
Procedure
Example
For class that is compiled by Java 6:
instrument.bat -in C:\java_code;C:\java_tests -baseline C:\llc\coverage_reports -verbose -output C:\instrumented_files
For
class that is compiled by Java 7:
instrument.bat -in C:\java_code;C:\java_tests -baseline C:\llc\coverage_reports -verbose -output C:\instrumented_files -javaVerifier
In
the following example, code coverage is enabled for the files in the Linux directories C:/java_source and C:/testcase_source and
backups are generated for these files. No baseline file is created,
no informational messages are printed, and the output files are stored
in C:/instrumented_files
instrument.sh -in /java_source:/testcase_source -saveBackup -output /instrumented_files
What to do next
- Generating code coverage reports from outside the workbench: Refer to Generating code coverage reports.
- Disabling code coverage from the command line: To disable classes instrumented from the command line, re-compile the project or replace the .class files with the .class.bak files, if saveBackup was enabled.
Note: If you encounter the Probekit error below when you use
the JDK shipped with v9.x of the product as JAVA_HOME, add the path
of jvm library to the PATH environment variable,
for example, on Windows, %JAVA_HOME%\jre\bin;%JAVA_HOME%\jre\bin\classic;
on Linux, ${JAVA_HOME}/jre/bin:${JAVA_HOME}/jre/bin/classic.
Probekit error:
source: Driver, message: Error loading the jvm library. Put the jre/bin and jre/bin/classic in the path.