-
Notifications
You must be signed in to change notification settings - Fork 1.2k
CoverageDataModel
Marc R. Hoffmann edited this page Aug 18, 2024
·
2 revisions
The coverage data model is the public API between the inner code coverage mechanics of JaCoCo and various integrations which processes the coverage information. Widely used integrations are:
- Reporting: The built-in reports (HTML, CSV, XML) are built on top of the coverage API whereby the XML schema closely follows the coverage data model.
- IDE Integration: Eclipse and Intellij plug-ins use JaCoCo APIs to reflect coverage information directly in the IDE UI.
The model was created under the following assumptions:
- Focus is on class files primarily compiled from Java source code, resulting in the following assumptions:
- A source file may result in multiple class files (inner classes, secondary classes, anonymous classes).
- Each class file results from at most one source file.
- The qualified name of a class is unique within a bundle. Different versions of a class can only be analyzed in separate bundles.
classDiagram
class ISourceNode
<<Abstract>> ISourceNode
class IBundleCoverage
class IPackageCoverage
class ISourceFileCoverage
class IClassCoverage
class IMethodCoverage
ISourceNode <|-- IClassCoverage
ISourceNode <|-- IMethodCoverage
ISourceNode <|-- ISourceFileCoverage
IPackageCoverage "*" *-- IBundleCoverage
IClassCoverage "*" *-- IPackageCoverage
ISourceFileCoverage "*" *-- IPackageCoverage
IMethodCoverage "*" *-- IClassCoverage
Entity | Identity within Scope | References |
---|---|---|
IBundleCoverage |
none, only application specific | IPackageCoverage* |
IPackageCoverage |
name package name within bundle |
IClassCoverage* , ISourceFileCoverage*
|
ISourceFileCoverage |
name local file name within package |
- |
IClassCoverage |
id global, name within bundle |
IMethodCoverage* |
IMethodCoverage |
name + desc not used
|
- |
The analysis process is performed in two main steps for each bundle:
- Analyze all class files of a bundle one after the other. For each visited class file a
IClassCoverage
object holding0..n
IMethodCoverage
objects is created. In the process Java debug information is used to assign each instruction and branch of a method to a line of source code (assuming all methods in a class are solely compiled from the same source file). - Create a
IBundleCoverage
instance by with the following algorithm:- Aggregate all
IClassCoverage
objects with the same source reference into aISourceFileCoverage
object. - Aggregate all
IClassCoverage
andISourceFileCoverage
with the same package reference to aIPackageCoverage
object. - Aggregate all
IPackageCoverage
objects into aIBundleCoverage
instance.
- Aggregate all
When aggregating ISourceNode
model elements referring to the same source file line coverage counters cannot simply be added. Instead coverage has to be evaluated line by line as instructions from different classes or methods my result from the same line of source code.