source: release-kits/lirk3/resources/gs3-release-maker/ant/docs/manual/OptionalTasks/jpcoverage.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 19.0 KB
Line 
1<html>
2<head>
3<title>JProbe Tasks</title>
4<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
5</head>
6<body>
7
8<h1><a name="jprobe">JProbe</a></h1>
9<p>by</p>
10<ul>
11 <li>Stephane Bailliez (<a href="mailto:[email protected]">[email protected]</a>)</li>
12</ul>
13<h2>Introduction</h2>
14
15<p>This task runs the tools from the JProbe suite.<br>
16For more information, visit <a href="http://www.sitraka.com">http://www.sitraka.com</a>.
17An evaluation version is available for download if you already don't own it.
18</p>
19
20<p>This task has been written using JProbe Suite Server Side 3.0.</p>
21
22<p>It is highly recommended to read the JProbe documentation to understand
23the values of the command line arguments described below. This
24document is less complete than the manual, it only gives the basic information
25and is not intended as a replacement to the manual.
26</p>
27
28<h2>Tasks</h2>
29<table border="0" cellspacing="0" cellpadding="3">
30 <tr>
31 <td><a href="#jpcoverage">JPCoverage</a></td>
32 <td>Measure coverage of Java code.</td>
33 </tr>
34 <tr>
35 <td><a href="#jpcovmerge">JPCovMerge</a></td>
36 <td>Merge different snapshots into one.</td>
37 </tr>
38 <tr>
39 <td><a href="#jpcovreport">JPCovReport</a></td>
40 <td>Create a report from a snapshot</td>
41 </tr>
42</table>
43
44<hr>
45
46<h2><a name="jpcoverage">JPCoverage</a></h2>
47Perform code covering functions by comparing source code line execution to the programï¿œs source code as a whole.
48
49<h3>Parameters</h3>
50<table border="1" cellpadding="2" cellspacing="0">
51<tr>
52 <td width="12%" valign="top"><b>Attribute</b></td>
53 <td width="78%" valign="top"><b>Description</b></td>
54 <td width="10%" valign="top"><b>Required</b></td>
55</tr>
56 <tr>
57 <td valign="top">home</td>
58 <td valign="top">The directory where JProbe is installed.</td>
59 <td align="center" valign="top">Yes</td>
60 </tr>
61 <tr>
62 <td valign="top">vm</td>
63 <td valign="top">
64 Indicates which virtual machine to run.
65 Must be one of "jdk117", "jdk118" or "java2".If "java2" is specified, the user is
66 also required to specify a path via <tt>javaexe</tt>, otherwise it will check if
67 the current executing VM is 1.2+ and use its java.home property to determine its
68 location.</td>
69 <td align="center" valign="top">No, default to embedded VM if 1.2+</td>
70 </tr>
71 <tr>
72 <td valign="top">javaexe</td>
73 <td valign="top">The path to the java executable.</td>
74 <td align="center" valign="top">No, use only for java2 vm.</td>
75 </tr>
76
77 <tr>
78 <td valign="top">applet</td>
79 <td valign="top">Run an applet. The default is false, unless the file under
80 analysis ends with htm or html.</td>
81 <td align="center" valign="top">No, default is "false".</td>
82 </tr>
83 <tr>
84 <td valign="top">seedname</td>
85 <td valign="top">Seed name for the temporary snapshot files (files will be named
86 seed.jpc, seed1.jpc, seed2.jpc, ...)</td>
87 <td align="center" valign="top">No, default to &quot;snapshot&quot;</td>
88 </tr>
89
90 <tr>
91 <td valign="top">exitprompt</td>
92 <td valign="top">Toggles display of the console prompt: &quot;Press Enter to close
93 this window.&quot; &quot;always&quot;: Always displays the prompt. &quot;never&quot;: Never displays the
94 prompt. &quot;error&quot;: Only displays prompt after an error.</td>
95 <td align="center" valign="top">No, default is "never"</td>
96 </tr>
97
98 <tr>
99 <td valign="top">finalsnapshot</td>
100 <td valign="top">Type of snapshot to send at program termination. Must be one
101 of &quot;none&quot;,&quot;coverage&quot;,&quot;all&quot;</td>
102 <td align="center" valign="top">No, default to &quot;coverage&quot;</td>
103 </tr>
104 <tr>
105 <td valign="top">recordfromstart</td>
106 <td valign="top">Must be one of "coverage", "all", "none". If you want
107 Coverage to start analyzing as soon as the program begins to run, use "all".
108 If not, select "none".</td>
109 <td align="center" valign="top">No, default to "coverage"</td>
110 </tr>
111 <tr>
112 <td valign="top">warnlevel</td>
113 <td valign="top">Set warning level (0-3, where 0 is the least amount of warnings).</td>
114 <td align="center" valign="top">No, default to 0</td>
115 </tr>
116 <tr>
117 <td valign="top">snapshotdir</td>
118 <td valign="top">The path to the directory where snapshot files are stored.
119 Choose a directory that is reachable by both the remote and local computers,
120 and enter the same path on the command line and in the viewer.</td>
121 <td align="center" valign="top">No, default to current directory</td>
122 </tr>
123 <tr>
124 <td valign="top">workingdir</td>
125 <td valign="top">The physical path to the working directory for the VM.</td>
126 <td align="center" valign="top">No, default is current directory.</td>
127 </tr>
128 <tr>
129 <td valign="top">tracknatives</td>
130 <td valign="top">Test native methods. Note that testing native methods with
131 Java 2 disables the JIT</td>
132 <td align="center" valign="top">No, default to &quot;false&quot;.</td>
133 </tr>
134 <tr>
135 <td valign="top">classname</td>
136 <td valign="top">the name of the class to analyze.</td>
137 <td align="center" valign="top">Yes</td>
138 </tr>
139</table>
140
141<h3><a name="nested">Nested Elements</a></h3>
142
143<h4>classpath</h4>
144<p><code>jpcoverage</code> supports a nested <code>&lt;classpath&gt;</code>
145element, that represents a <a href="../using.html#path">PATH like
146structure</a>.</p>
147
148<h4>jvmarg</h4>
149
150<p>Additional parameters may be passed to the VM via nested <code>&lt;jvmarg&gt;</code>
151attributes, for example:</p>
152
153<pre></pre>
154<blockquote>
155<pre>&lt;jpcoverage home=&quot;c:\jprobe&quot; classname=&quot;MyClass&quot;&gt;
156 &lt;jvmarg value=&quot;-classic&quot;/&gt;
157 &lt;classpath path=&quot;.&quot;/&gt;
158&lt;/jpcoverage&gt;
159</pre>
160</blockquote>
161would run the coverage on &quot;MyClass&quot; in classic mode VM.
162
163<p><code>&lt;jvmarg&gt;</code> allows all attributes described in <a
164href="../using.html#arg">Command line arguments</a>.</p>
165
166<h4>arg</h4>
167
168<p>
169Parameters may be passed to the executed class via nested <tt>&lt;arg&gt;</tt>
170attributes, as described in <a href="../using.html#arg">Command line arguments</a>.
171</p>
172
173<h4>socket</h4>
174<p>Define a host and port to connect to if you want to do remote viewing.
175</p>
176<table border="1" cellpadding="2" cellspacing="0">
177<tr>
178 <td width="12%" valign="top"><b>Attribute</b></td>
179 <td width="78%" valign="top"><b>Description</b></td>
180 <td width="10%" valign="top"><b>Required</b></td>
181</tr>
182 <tr>
183 <td valign="top">host</td>
184 <td valign="top">the host name/ip of the machine on which the Viewer is running</td>
185 <td align="center">No, default to localhost</td>
186 </tr>
187 <tr>
188 <td valign="top">port</td>
189 <td valign="top">The port number on which you will connect to the Viewer</td>
190 <td align="center">No, default to 4444</td>
191 </tr>
192</table>
193
194
195
196<h4>filters</h4>
197
198<p>Defines class/method filters based on pattern matching.
199The syntax is filters is similar to a <a href="../CoreTypes/fileset.html">fileset</a>.
200</p>
201
202<table border="1" cellpadding="2" cellspacing="0">
203<tr>
204 <td width="12%" valign="top"><b>Attribute</b></td>
205 <td width="78%" valign="top"><b>Description</b></td>
206 <td width="10%" valign="top"><b>Required</b></td>
207</tr>
208 <tr>
209 <td valign="top">defaultexclude</td>
210 <td valign="top">As a default, the coverage excludes all classes and methods.
211 Default filters are equivalent to
212<pre>
213 &lt;filters&gt;
214 &lt;exclude class=&quot;*&quot; method=&quot;*&quot;/&gt;
215 &lt;/filters&gt;
216</pre>
217 </td>
218 <td align="center">No, default to "true"</td>
219 </tr>
220</table>
221<p>
222As seen above, nested elements are <b><tt>include</tt></b> and <b><tt>exclude</tt></b>
223with a <tt>name</tt> attribute.
224</p>
225<blockquote>
226<table border="1" cellpadding="2" cellspacing="0">
227<tr>
228 <td width="12%" valign="top"><b>Attribute</b></td>
229 <td width="78%" valign="top"><b>Description</b></td>
230 <td width="10%" valign="top"><b>Required</b></td>
231</tr>
232 <tr>
233 <td valign="top">class</td>
234 <td valign="top">The class mask as a simple regular expression</td>
235 <td align="center">No, defaults to "*"</td>
236 </tr>
237 <tr>
238 <td valign="top">method</td>
239 <td valign="top">The method mask as a simple regular expression</td>
240 <td align="center">No, defaults to "*"</td>
241 </tr>
242 <tr>
243 <td valign="top">enabled</td>
244 <td valign="top">is the filter enabled?</td>
245 <td align="center">No, defaults to true</td>
246 </tr>
247</table>
248</blockquote>
249
250<h3>Example of filters</h3>
251<blockquote>
252 <pre>&lt;filters&gt;
253 &lt;include class=&quot;com.mycompany.*&quot; method=&quot;*&quot;/&gt;
254 &lt;exclude class=&quot;com.mycompany.MyClass&quot; method=&quot;test*&quot;/&gt;
255&lt;/filters&gt;</pre>
256</blockquote>
257
258reports the coverage on all packages, classes and methods from <tt>com.mycompany</tt>
259except all methods starting by <tt>test</tt> on the class <tt>MyClass</tt>
260in the package <tt>com.mycompany</tt>
261
262<h4>triggers</h4>
263
264<p>Define a number of events to use for interacting with the collection
265of data performed during coverage. For example you may run a whole application
266but only decide to collect data once it reaches a certain method and once it
267exits another one.</p>
268<p>
269The only type of nested element is the <tt>method</tt> element (triggers are performed
270on method) and it has the following attributes:
271</p>
272<table border="1" cellpadding="2" cellspacing="0">
273<tr>
274 <td width="12%" valign="top"><b>Attribute</b></td>
275 <td width="78%" valign="top"><b>Description</b></td>
276 <td width="10%" valign="top"><b>Required</b></td>
277</tr>
278 <tr>
279 <td valign="top">name</td>
280 <td valign="top">The name of the method(s) as a regular expression. The name
281 is the fully qualified name on the form <tt>package.classname.method</tt></td>
282 <td align="center" valign="top">Yes</td>
283 </tr>
284 <tr>
285 <td valign="top">event</td>
286 <td valign="top">the event on the method that will trigger the action. Must be
287 &quot;enter&quot; or &quot;exit&quot;.</td>
288 <td align="center" valign="top">Yes</td>
289 </tr>
290 <tr>
291 <td valign="top">action</td>
292 <td valign="top">the action to execute. Must be one of &quot;clear&quot;,
293 &quot;pause&quot;, &quot;resume&quot;, &quot;snapshot&quot;, &quot;suspend&quot;,
294 or &quot;exit&quot;. They respectively clear recording, pause recording,
295 resume recording, take a snapshot, suspend the recording and exit the program.
296</td>
297 <td align="center" valign="top">Yes</td>
298 </tr>
299</table>
300
301<h3>Example of triggers</h3>
302<blockquote>
303<pre>&lt;triggers&gt;
304 &lt;method name=&quot;ClassName.*()&quot; event=&quot;enter&quot; action=&quot;snapshot&quot;/&gt;
305 &lt;method name=&quot;ClassName.MethodName()&quot; event=&quot;exit&quot; action=&quot;exit&quot;/&gt;
306&lt;/triggers&gt;
307</pre>
308</blockquote>
309
310<p>Will take a snapshot when it enters any method of the class <tt>ClassName</tt>
311and will exit the program once it exits the method <tt>MethodName</tt> of the
312same class.</p>
313
314<hr>
315<h2><a name="jpcovmerge">JPCovMerge</a></h2>
316
317<h3>Description</h3>
318
319<p>Perform the merge of several snapshots into a single one.</p>
320
321<h3>Parameters</h3>
322<table border="1" cellpadding="2" cellspacing="0">
323<tr>
324 <td width="12%" valign="top"><b>Attribute</b></td>
325 <td width="78%" valign="top"><b>Description</b></td>
326 <td width="10%" valign="top"><b>Required</b></td>
327</tr>
328<tr>
329 <td valign="top">home</td>
330 <td valign="top">The directory where JProbe is installed.</td>
331 <td align="center" valign="top">Yes</td>
332</tr>
333<tr>
334 <td valign="top">tofile</td>
335 <td valign="top">the output filename that will be the result
336 of the name.</td>
337 <td align="center" valign="top">Yes</td>
338</tr>
339<tr>
340 <td valign="top">verbose</td>
341 <td valign="top">Perform the merge in verbose mode giving
342 details about the snapshot processing.</td>
343 <td align="center" valign="top">No. Default to false</td>
344</tr>
345</table>
346
347<p>
348<tt>jpcovmerge</tt> collects snapshots using the nested <a href="../CoreTypes/fileset.html"><code>&lt;FileSet&gt;</code></a>
349element.
350</p>
351
352<h3>Example of merge</h3>
353<blockquote>
354<pre>&lt;jpcovmerge home=&quot;c:\jprobe&quot; tofile=&quot;merge.jpc&quot; verbose=&quot;true&quot;&gt;
355 &lt;fileset dir=&quot;./snapshots&quot;&gt;
356 &lt;include name=&quot;snap*.jpc&quot;/&gt;
357 &lt;/fileset&gt;
358&lt;/jpcovmerge&gt;
359</pre>
360</blockquote>
361<p>
362would run the merge in verbose mode on all snapshot files starting by <tt>snap</tt> in the
363directory <tt>snapshots</tt>. The resulting file will be named <tt>merge.jpc</tt>.
364</p>
365
366<hr>
367
368<h2><a name="jpcovreport">JPCovReport</a></h2>
369
370<h3>Description</h3>
371
372<p>Generate a readable/printable report of a snapshot. Note that you will need <a href="http://jakarta.apache.org/oro/index.html">Jakarta
373Oro</a> in Ant classpath, to run the <tt>reference</tt> feature.</p>
374
375<h3>Parameters</h3>
376<table border="1" cellpadding="2" cellspacing="0">
377<tr>
378 <td width="12%" valign="top"><b>Attribute</b></td>
379 <td width="78%" valign="top"><b>Description</b></td>
380 <td width="10%" valign="top"><b>Required</b></td>
381</tr>
382<tr>
383 <td valign="top">home</td>
384 <td valign="top">The directory where JProbe is installed.</td>
385 <td align="center" valign="top">Yes</td>
386</tr>
387<tr>
388 <td valign="top">format</td>
389 <td valign="top">The format of the generated report. Must be &quot;xml&quot;, &quot;html&quot; or &quot;text&quot;</td>
390 <td align="center" valign="top">No, default to &quot;html&quot;</td>
391</tr>
392<tr>
393 <td valign="top">type</td>
394 <td valign="top">The type of report to be generated. Must be &quot;executive&quot;,
395 &quot;summary&quot;, &quot;detailed&quot; or &quot;verydetailed&quot;</td>
396 <td align="center" valign="top">No. Default to &quot;detailed&quot;</td>
397</tr>
398<tr>
399 <td valign="top">percent</td>
400 <td valign="top">A numeric value for the threshold for printing methods. Must
401 be between 0 and 100.</td>
402 <td align="center" valign="top">No, default to 100</td>
403</tr>
404<tr>
405 <td valign="top">snapshot</td>
406 <td valign="top">The name of the snapshot file that is the source to the report.</td>
407 <td align="center" valign="top">Yes</td>
408</tr>
409<tr>
410 <td valign="top">tofile</td>
411 <td valign="top">The name of the generated output file</td>
412 <td align="center" valign="top">Yes</td>
413</tr>
414<tr>
415 <td valign="top">includesource</td>
416 <td valign="top">Include text of the source code lines. Only applies to
417 format=&quot;xml&quot; and type=&quot;verydetailed&quot;</td>
418 <td align="center" valign="top">No. Defaults to &quot;yes&quot;</td>
419</tr>
420</table>
421
422<h4>sourcepath</h4>
423
424<p>
425Path to source files can be set via nested sourcepath elements that are <a href="../using.html#path">PATH like structures</a>.
426</p>
427
428<h4>reference (only applies to format=&quot;xml&quot;)</h4>
429
430<p>A reference is a set of classes whose coverage information will be checked
431against. Since Coverage is only able to give you information about loaded
432classes, it will only report classes that were at least used in some points in
433your tests,
434therefore you will not be able to know what classes are not exercised at all
435during your tests. The reference is an additional feature that will analyze the
436bytecode of all classes in a given classpath that match some filters and modify
437the XML report accordingly. In short, it will:
438</p>
439
440<ul>
441 <li>remove the classes that do not exists in the reference classpath. (For
442 example you might have in your report some helper test classes that you do
443 not want to appear in the report, but are unable to filter without adding
444 hundred of filters for all your classes).</li>
445 <li>add classes that exists in the reference set and match the filters but are
446 not reported.</li>
447 <li>remove abstract methods that are incorrectly reported in JProbe 3.0
448 (should be fixed in a later SP)</li>
449 <li>remove classes/methods that do not match the filters.</li>
450</ul>
451<blockquote>
452 <h4>classpath
453</h4>
454
455 <p>
456Path to the reference set of files can be set via nested classpath elements that are <a href="../using.html#path">PATH like structures</a>.
457</p>
458
459 <h4>filters
460</h4>
461
462 <p>Nested elements are <b><tt>include</tt></b> and <b><tt>exclude</tt></b>
463with a <tt>class </tt>and&nbsp; <tt>method </tt>attribute.
464</p>
465</blockquote>
466<blockquote>
467<table border="1" cellpadding="2" cellspacing="0">
468<tr>
469 <td width="12%" valign="top"><b>Attribute</b></td>
470 <td width="78%" valign="top"><b>Description</b></td>
471 <td width="10%" valign="top"><b>Required</b></td>
472</tr>
473 <tr>
474 <td valign="top">class</td>
475 <td valign="top">The class mask as a simple regular expression</td>
476 <td align="center">No, default to *</td>
477 </tr>
478 <tr>
479 <td valign="top">method</td>
480 <td valign="top">The method mask as a simple regular expression</td>
481 <td align="center">No, default to *</td>
482 </tr>
483</table>
484</blockquote>
485
486<h3>Example of report</h3>
487<blockquote>
488<pre>&lt;jpcovreport home=&quot;c:\jprobe&quot; snapshot=&quot;merge.jpc&quot; format=&quot;xml&quot; tofile=&quot;result.xml&quot;&gt;
489 &lt;sourcepath path=&quot;./src&quot;/&gt;
490 &lt;reference&gt;
491 &lt;classpath path=&quot;./bin/classes&quot;/&gt;
492 &lt;filters&gt;
493 &lt;include class=&quot;com.mycompany.*&quot;/&gt;
494 &lt;exclude class=&quot;com.mycompany.MyClass&quot; method=&quot;test*&quot;/&gt;
495 &lt;/filters&gt;
496 &lt;/reference&gt;
497&lt;/jpcovreport&gt;
498</pre>
499</blockquote><p>
500would generate the report of the file <tt>merge.jpc</tt> and write it to <tt>result.xml</tt>
501using the source path <tt>src</tt>. As well, it will modify the result.xml by
502analyzing all classes in the <tt>./bin/classes</tt> that are port of the package
503<tt>com.mycompany</tt> except the method that start by <tt>test</tt> from the class <tt>MyClass</tt>.
504</p>
505
506<h3>Recommendation</h3>
507
508<p>If you generate your main code and your testcases in a separate directory,
509say bin/classes and test/classes. You should mostly end up with a reference such
510as:</p>
511<blockquote>
512<pre>&lt;reference&gt;
513&nbsp;&nbsp;&nbsp; &lt;classpath path=&quot;./bin/classes&quot;/&gt;
514&lt;/reference&gt;</pre>
515</blockquote>
516<p>With such a reference, your XML report will be cleaned up against parasite
517classes from your testcases (that as a common practice, generally match the
518exact package structure of the class you exercise).</p>
519<h3>HTML reports</h3>
520<p>You will find in Ant etc directory a stylesheet called coverage-frames.xsl.
521This file can be used to generate a framed report a la javadoc similar to the
522one for JUnit. It needs either Xalan 1.2.2 or Xalan 2.x.</p>
523<p>Xalan 1.2.2 (you must have xalan.jar and bsf.jar in your classpath)
524</p>
525<pre>&lt;style processor=&quot;xalan&quot; in=&quot;./reports/xml/results.xml&quot; out=&quot;./reports/html/dummy.file&quot;
526 style=&quot;${ant.home}/etc/coverage-frames.xsl&quot;&gt;
527 &lt;param name=&quot;output.dir&quot; expression=&quot;'${basedir}/reports/html'&quot;/&gt;
528&lt;/style&gt;</pre>
529<p>Xalan 2.x (note the parameter without single quote)</p>
530<pre>&lt;style processor=&quot;trax&quot; in=&quot;./reports/xml/results.xml&quot; out=&quot;./reports/html/dummy.file&quot;
531 style=&quot;${ant.home}/etc/coverage-frames.xsl&quot;&gt;
532&nbsp; &lt;param name=&quot;output.dir&quot; expression=&quot;${basedir}/reports/html&quot;/&gt;
533&lt;/style&gt;</pre>
534
535<hr>
536<p align="center">Copyright &copy; 2001-2002,2004 The Apache Software Foundation. All rights
537Reserved.</p>
538</body>
539</html>
Note: See TracBrowser for help on using the repository browser.