Here is the task for Sitraka JProbe Coverage.
It has been tested under Windows w/ JProbe Server Side suite 2.8.0 and Solaris w/ 2.8.1.
There seems to be a argument parsing bug under solaris when running jpcovmerge (It does not even work manually).
I have passed this over to Sitraka and waiting for an answer.
HTML Documentation is included.
The following definitions need to be added to default.properties
jpcoverage=org.apache.tools.ant.taskdefs.optional.sitraka.coverage.Coverage
jpcovreport=org.apache.tools.ant.taskdefs.optional.sitraka.coverage.CovReport
jpcovmerge=org.apache.tools.ant.taskdefs.optional.sitraka.coverage.CovMerge
I gave it a try looping back to 'ant run-tests' FYI I included the coverage report for the tests.
There will be improvement very soon for jpcovreport filters. As of now filters are expressed as a string conforming to the real syntax. As the syntax, is not specified in the command line, nor in the help file, nor in the printed doc, nor in the online doc, I wasn't sure if the syntax was similar or not to other filters and didn't have time to try it.
Will do it asap and send a patch for it if necessary.
Cheers,
--
St�phane Bailliez
Software Engineer, Paris - France
iMediation - http://www.imediation.com
Disclaimer: All the opinions expressed above are mine and not those from my company.
Socket.java
Description: Binary data
CovMerge.java
Description: Binary data
CovReport.java
Description: Binary data
Filters.java
Description: Binary data
Coverage.java
Description: Binary data
Triggers.java
Description: Binary data
JProbe
by
- Stephane Bailliez ([EMAIL PROTECTED])
Introduction
This task runs the tools from the JProbe suite.
For more information, visit http://www.sitraka.com.
An evaluation version is available for download if you already don't own it.
This task has been written using JProbe Suite Server Side 2.8.1.
It is highly recommended to read the JProbe documentation to understand the values of the command line arguments described below. This document is less complete than the manual, it only gives the basic information and is not intended as a replacement to the manual.
Tasks
| JPCoverage | Measure coverage of Java code. |
| JPCovMerge | Merge different snapshots into one. |
| JPCovReport | Create a report from a snapshot |
JPCoverage
Perform code covering functions by comparing source code line execution to the program�s source code as a whole.Parameters
| Attribute | Description | Required |
| home | The directory where is intalled JProbe Coverage. Should look like <jprobehome>/Coverage | Yes |
| vm | Indicates which virtual machine to run. Must be one of "jdk117", "jdk118" or "java2".If "java2" is specified, the user is also required to specify a path via javahome, otherwise it will look in the registry for the default 1.2.x (Java 2) VM. | No, default to registry 1.2.x key |
| javahome | For Java 2 only, specifies the path of the jdk1.2.x virtual machine to be used. This is only valid when specifying the vm="java2". | No, use only for java2 |
| javaexe | Similar to javahome, except this is the path to the java executable. | No, use only for java2 |
| applet | Run an applet. The default is false, unless the file under analysis ends with htm or html. | No, default is "false". |
| seedname | Seed name for the temporary snapshot files (files will be named seed.jpc, seed1.jpc, seed2.jpc, ... | No, default to "snapshot" |
| exitprompt | Toggles display of the console prompt: "Press Enter to close this window." "always": Always displays the prompt. "never": Never displays the prompt. "error": Only displays prompt after an error. | No, default is "never" |
| finalsnapshot | Type of snapshot to send at program termination. Must be one of "none","coverage","all" | No, default to "coverage" |
| recordfromstart | Must be one of "coverage", "all", "none". If you want Coverage to start analyzing as soon as the program begins to run, use "all". If not, select "none". | No, default to "coverage" |
| warnlevel | Set warning level (0-3, where 0 is the least amount of warnings). | No, default to 0 |
| snapshotdir | The path to the directory where snapshot files are stored. Choose a directory that is reachable by both the remote and local computers, and enter the same path on the command line and in the viewer. | No, default to current directory |
| workingdir | The physical path to the working directory for the VM. | No, default is current directory. |
| tracknatives | Test native methods. Note that testing native methods with Java 2 disables the JIT | No, default to "false". |
| classname | the name of the class to analyze. | Yes |
Nested Elements
classpath
jpcoverage supports a nested <classpath>
element, that represents a PATH like
structure.
jvmarg
Additional parameters may be passed to the VM via nested <jvmarg>
attributes, for example:
would run the coverage on "MyClass" in classic mode VM.<jpcoverage home="c:\jprobe\coverage" classname="MyClass"> <jvmarg value="-classic"/> <classpath path="."/> </jpcoverage>
<jvmarg>allows all attributes described in Command line arguments.arg
Parameters may be passed to the executed class via nested <arg> attributes, as described in Command line arguments.
socket
Define a host and port to connect to if you want to do remote viewing.
| Attribute | Description | Required |
| host | the host name/ip of the machine on which the Viewer is running | No, default to localhost |
| port | The port number on which you will connect to the Viewer | No, default to 4444 |
filters
Defines class/method filters based on pattern matching. The syntax is filters is similar to a fileset.
| Attribute | Description | Required |
| defaultexclude | As a default, the coverage does not cover objects coming
from the jdk, Sun, Microsoft, and KLGroup. Default filters are equivalent
to
<filters>
<exclude name="java.*" />
<exclude name="javax.*" />
<exclude name="com.sun.*" />
<exclude name="sun.*" />
<exclude name="com.ms.*" />
<exclude name="com.klgroup.*" />
</filters>
|
No, default to "true" |
As seen above, nested elements are include and exclude with a name attribute.
| Attribute | Description | Required |
| name | The name of the class/method as a regular _expression_ | Yes |
Example of filters
reports the coverage on all packages, classes and methods from com.mycompany except all methods starting by test on the class MyClass in the package com.mycompany<filters> <include name="com.mycompany.*" /> <exclude name="com.mycompany.MyClass.test*()" /> </filters>
triggers
Define a number of events to use for interacting with the collection of data performed during coverage. For example you may run a whole application but only decide to collect data once it reaches a certain method and once it exits another one.
The only type of nested element is the method element (triggers are performed on method) and it has the following attributes:
| Attribute | Description | Required |
| name | The name of the method(s) as a regular _expression_. The name is the fully qualified name on the form package.classname.method | Yes |
| event | the event on the method that will trigger the action. Must be "enter" or "exit". | Yes |
| action | the action to execute. Must be one of "clear", "pause", "resume", "snapshot", "suspend", or "exit". They respectively clear recording, pause recording, resume recording, take a snapshot, suspend the recording and exit the program. | Yes |
Example of triggers
<triggers> <method name="ClassName.*()" event="enter" action=""/> <method name="ClassName.MethodName()" event="exit" action=""/> </triggers>
Will take a snapshot when it enters any method of the class ClassName and will exit the program once it exits the method MethodName of the same class.
JPCovMerge
Description
Perform the merge of several snapshots into a single one.
Parameters
| Attribute | Description | Required |
| home | The directory where is intalled JProbe Coverage. Should look like <jprobehome>/Coverage | Yes |
| tofile | the output filename that will be the result of the name. | Yes |
| verbose | Perform the merge in verbose mode giving details about the snapshot processing. | No. Default to false |
jpcovmerge collects snapshots using the nested <FileSet>
element.
Example of merge
<jpcovreport home="c:\jprobe\coverage" tofile="merge.jpc" verbose="true";> <fileset dir="./snapshots"> <include name="snap*.jpc"/> </fileset> </jpcovreport>
would run the merge in verbose mode on all snapshot files starting by snap in the directory snapshots. The resulting file will be named merge.jpc.
JPCovReport
Description
Generate a readable/printable report of a snapshot.
Parameters
| Attribute | Description | Required |
| home | The directory where is intalled JProbe Coverage. Should look like <jprobehome>/Coverage | Yes |
| format | The format of the generated report. Must be "html" or "text" | No, default to "html" |
| type | The type of report to be generated. Must be "executive", "summary", "detailed" or "verydetailed" | No. Default to "detailed" |
| percent | A numeric value for the threshold for printing methods. Must be between 0 and 100. | No, default to 100 |
| snapshot | The name of the snapshot file that is the source to the report. | Yes |
| tofile | The name of the generated output file | Yes |
sourcepath
Path to source files can be set via nested sourcepath elements that are PATH like structures.
Example of report
<jpcovreport home="c:\jprobe\coverage" snapshot="merge.jpc" tofile="result.html"> <sourcepath path="./src"/> </jpcovreport>
would generate the report of the file merge.jpc and write it to result.html using the source path src
Title: JProbe (tm) Coverage Report of org.apache.tools.ant.MainJProbeTM Coverage Report of org.apache.tools.ant.Main
| JProbe Coverage version: | 2.8.1 |
| programDate | 02-Feb-01 7:04:02 PM |
| elapsedTime | 6125 ms |
| machineName | aramis |
| processorSpeed | 450 |
| osName | SunOS |
| osVersion | 5 |
| machineType | sun4u |
| Line Information: | Available |
| Name Total | Calls 76942 | Methods Missed 77.8% | Total Methods 1970 | Lines Missed 82.6% | Total Lines 11441 |
| org.apache.crimson.parser | 44589 | 48.3% | 203 | 67.1% | 2159 |
| org.apache.tools.ant | 11405 | 45.3% | 289 | 59.2% | 1744 |
| org.apache.crimson.util | 9904 | 68.4% | 19 | 85.3% | 245 |
| org.xml.sax.helpers | 8582 | 60.5% | 86 | 60.9% | 248 |
| org.apache.tools.ant.types | 1788 | 74.9% | 171 | 82.9% | 753 |
| org.apache.tools.ant.taskdefs | 362 | 92.3% | 601 | 95.0% | 3542 |
| org.xml.sax | 275 | 65.9% | 44 | 66.7% | 81 |
| org.apache.tools.ant.taskdefs.optional.junit | 23 | 84.1% | 113 | 89.6% | 536 |
| org.apache.crimson.jaxp | 6 | 66.7% | 15 | 44.4% | 36 |
| org.apache.xalan.processor | 4 | 83.3% | 24 | 84.8% | 164 |
| org.apache.tools.ant.taskdefs.optional | 3 | 96.1% | 77 | 98.6% | 425 |
| org.apache.xml.utils | 1 | 88.9% | 9 | 96.8% | 31 |
| org.apache.tools.ant.taskdefs.optional.vss | 0 | 100.0% | 22 | 100.0% | 111 |
| org.apache.tools.ant.taskdefs.optional.javacc | 0 | 100.0% | 42 | 100.0% | 159 |
| org.apache.tools.ant.taskdefs.optional.jsp | 0 | 100.0% | 9 | 100.0% | 104 |
| org.apache.tools.ant.taskdefs.optional.clearcase | 0 | 100.0% | 67 | 100.0% | 244 |
| org.apache.tools.ant.taskdefs.optional.sitraka.coverage | 0 | 100.0% | 49 | 100.0% | 277 |
| org.apache.tools.ant.taskdefs.optional.depend | 0 | 100.0% | 14 | 100.0% | 139 |
| org.apache.tools.ant.taskdefs.optional.dotnet | 0 | 100.0% | 77 | 100.0% | 241 |
| org.apache.tools.ant.taskdefs.optional.jlink | 0 | 100.0% | 11 | 100.0% | 49 |
| org.apache.tools.ant.taskdefs.optional.metamata | 0 | 100.0% | 7 | 100.0% | 67 |
| org.apache.tools.ant.taskdefs.optional.ejb | 0 | 100.0% | 16 | 100.0% | 68 |
| org.apache.tools.ant.taskdefs.optional.sound | 0 | 100.0% | 5 | 100.0% | 18 |
| Name Total | Calls 9904 | Methods Missed 68.4% | Total Methods 19 | Lines Missed 85.3% | Total Lines 245 |
| XmlChars | 9902 | 60.0% | 10 | 73.8% | 103 |
| MessageCatalog | 2 | 77.8% | 9 | 93.7% | 142 |
| Name Total | Calls 4 | Methods Missed 83.3% | Total Methods 24 | Lines Missed 84.8% | Total Lines 164 |
| TransformerFactoryImpl | 4 | 83.3% | 24 | 84.8% | 164 |
| Name Total | Calls 1 | Methods Missed 88.9% | Total Methods 9 | Lines Missed 96.8% | Total Lines 31 |
| DefaultErrorHandler | 1 | 88.9% | 9 | 96.8% | 31 |
