next up previous contents index
Next: JUnit Up: JProbe Coverage Previous: JPCovMerge   Contents   Index

JPCovReport

Description

Generate a readable/printable report of a snapshot. Note that you will need Jakarta Oro in Ant classpath, to run the reference feature.

Parameters

Attribute Description Required
home The directory where JProbe is intalled. Yes
format The format of the generated report. Must be "xml", "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
includesource Include text of the source code lines. Only applies to format="xml" and type="verydetailed" No. Defaults to "yes"

sourcepath

Path to source files can be set via nested sourcepath elements that are PATH like structures. reference (only applies to format="xml")

A reference is a set of classes whose coverage information will be checked against. Since Coverage is only able to give you information about loaded classes, it will only report classes that were at least used in some points in your tests, therefore you will not be able to know what classes are not exercised at all during your tests. The reference is an additional feature that will analyze the bytecode of all classes in a given classpath that match some filters and modify the XML report accordingly. In short, it will:

classpath

Path to the reference set of files can be set via nested classpath elements that are PATH like structures.

filters

Nested elements are include and exclude with a class and method attribute.

Attribute Description Required
class The class mask as a simple regular expression No, default to *
method The method mask as a simple regular expression No, default to *

Example of report

<jpcovreport home="c:\jprobe" snapshot="merge.jpc" 
  format="xml" tofile="result.xml">
  <sourcepath path="./src"/>
  <reference>
    <classpath path="./bin/classes"/>
    <filters>
      <include class="com.mycompany.*"/>
      <exclude class="com.mycompany.MyClass" method="test*"/>
    </filters>
  </reference>
</jpcovreport>
would generate the report of the file merge.jpc and write it to result.xml using the source path src. As well, it will modify the result.xml by analyzing all classes in the ./bin/classes that are port of the package com.mycompany except the method that start by test from the class MyClass.

Recommendation

If you generate your main code and your testcases in a separate directory, say bin/classes and test/classes. You should mostly end up with a reference such as:

<reference>
    <classpath path="./bin/classes"/>
</reference>
With such a reference, your XML report will be cleaned up against parasite classes from your testcases (that as a common practice, generally match the exact package structure of the class you exercise).

HTML reports

You will find in Ant etc directory a stylesheet called coverage-frames.xsl. This file can be used to generate a framed report a la javadoc similar to the one for JUnit. It needs either Xalan 1.2.2 or Xalan 2.x.

Xalan 1.2.2 (you must have xalan.jar and bsf.jar in your classpath)

<style processor="xalan" in="./reports/xml/results.xml" out="./reports/html/dummy.file"
 style="${ant.home}/etc/coverage-frames.xsl">
    <param name="output.dir" expression="'${basedir}/reports/html'"/>
</style>
Xalan 2.x (note the parameter without single quote)
<style processor="trax" in="./reports/xml/results.xml" out="./reports/html/dummy.file"
 style="${ant.home}/etc/coverage-frames.xsl">
  <param name="output.dir" expression="${basedir}/reports/html"/>
</style>


next up previous contents index
Next: JUnit Up: JProbe Coverage Previous: JPCovMerge   Contents   Index
Andrew Marlow 2003-07-08