blob: 1aa3716a2b78ee677dc874c52f76f8a22461b8ab [file] [log] [blame]
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +02001<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
4<head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <link rel="stylesheet" href=".resources/doc.css" charset="UTF-8" type="text/css" />
7 <link rel="shortcut icon" href=".resources/report.gif" type="image/gif" />
8 <title>JaCoCo - FAQ</title>
9</head>
10<body>
11
12<div class="breadcrumb">
13 <a href="../index.html" class="el_report">JaCoCo</a> &gt;
14 <a href="index.html" class="el_group">Documentation</a> &gt;
15 <span class="el_source">FAQ</span>
16</div>
17<div id="content">
18
19<h1>FAQ</h1>
20
21<p>
22 This is a compilation of questions that have been asked by JaCoCo users
23 before.
24</p>
25
26<h3>Does JaCoCo have a plug-in for [Eclipse|Netbeans|Whatever...]?</h3>
27<p>
28 See <a href="integrations.html">this list</a> for current integrations with
29 various tools.
Marc R. Hoffmann08db74b2013-01-16 07:58:13 +010030</p>
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +020031
32<h3>Why do I get the error "Can't add different class with same name"?</h3>
33<p>
34 For coverage report generation all classes within a group must have unique
35 names. You get this error during report generation if JaCoCo is supplied with
36 multiple different class files with the same name. To fix this remove those
37 duplicate classes or create separate reports or report groups for each version.
Marc R. Hoffmann08db74b2013-01-16 07:58:13 +010038</p>
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +020039
Marc R. Hoffmannf6787ed2012-11-13 23:03:55 +010040<h3>Code with exceptions shows no coverage. Why?</h3>
41<p>
42 JaCoCo determines code execution with so called probes. Probes are inserted
43 into the control flow at certain positions. Code is considered as executed
44 when a subsequent probe has been executed. In case of exceptions such a
45 sequence of instructions is aborted somewhere in the middle and not marked as
46 executed.
47</p>
48
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +020049<h3>Why does the coverage report not show line coverage figures?</h3>
50<p>
Marc R. Hoffmann9a7379b2012-09-21 21:48:35 +020051 JaCoCo is based on class files analysis. To calculate line coverage class
52 files must contain line number attributes. For this your code must be compiled
53 with debug information.
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +020054</p>
55
56<h3>Why does the coverage report coverage report not show highlighted source code?</h3>
57<p>
58 Make sure the following prerequisites are fulfilled to get source code
59 highlighting in JaCoCo coverage reports:
60</p>
61<ul>
62 <li>Class files must be compiled with debug information to contain line numbers.</li>
63 <li>Source files must be properly supplied at report generation time. I.e.
64 specified source folders must be the direct parent of the folders that
65 define the Java packages.</li>
66</ul>
67
68<h3>Why does a class show as not covered although it has been executed?</h3>
69<p>
70 First make sure execution data has been collected. For this select the
71 <i>Sessions</i> link on the top right corner of the HTML report and check
72 whether the class in question is listed. If it is listed but not linked the
73 class at execution time is a different class file. Make sure you're using the
Marc R. Hoffmann9a7379b2012-09-21 21:48:35 +020074 exact same class file at runtime as for report generation. Note that some
75 tools (e.g. EJB containers, mocking frameworks) might modify your class files
76 at runtime.
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +020077</p>
78
79<h3>Why are Java interface types not shown in the coverage reports?</h3>
80<p>
81 Java interface methods do not contain code, therefore code coverage cannot
82 be evaluated. Indeed code coverage is recorded for the implementation classes.
83 The same applies to abstract methods in abstract classes.
84</p>
85
Marc R. Hoffmann9a7379b2012-09-21 21:48:35 +020086<h3>Can I collect coverage information without stopping the JVM?</h3>
87<p>
88 The JaCoCo <a href="agent.html">agent</a> can be configured for remote control
89 via TCP/IP sockets. This allows to collect execution data at any point in time
90 from a running JVM. The <a href="ant.html#dump"><code>dump</code></a> Ant task
91 can be used to request dumps. The remote control feature also allows you to
92 reset execution data.
93</p>
94
Marc R. Hoffmann08db74b2013-01-16 07:58:13 +010095<h3>My code uses reflection. Why does it fail when I execute it with JaCoCo?</h3>
96<p>
97 To collect execution data JaCoCo instruments the classes under test which adds
98 two members to the classes: A private static field <code>$jacocoData</code>
99 and a private static method <code>$jacocoInit()</code>. Both members are
100 marked as synthetic.
101</p>
102<p>
103 Please change your code to ignore synthetic members. This is a good practice
104 anyways as also the Java compiler creates synthetic members in certain
105 situation.
106</p>
107
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +0200108</div>
109<div class="footer">
110 <span class="right"><a href="@jacoco.home.url@">JaCoCo</a> @qualified.bundle.version@</span>
111 <a href="license.html">Copyright</a> &copy; @copyright.years@ Mountainminds GmbH &amp; Co. KG and Contributors
112</div>
113
114</body>
115</html>