I'm trying to understand JaCoCo rules but there are not many great examples around. Every thread I see circulates the same examples from the docs.
I see 3 different metrics:
- element types (BUNDLE, PACKAGE, CLASS, SOURCEFILE or METHOD)
- limits (INSTRUCTION, LINE, BRANCH, COMPLEXITY, METHOD, CLASS)
- values (TOTALCOUNT, COVEREDCOUNT, MISSEDCOUNT, COVEREDRATIO, MISSEDRATIO)
I understand that "element types" represent the scope of each rule, fair enough.
- BUNDLE: That represents the project as a whole
- PACKAGE: Each java package
- CLASS: As name states, a single class
- SOURCEFILE: How is this different than the
CLASS
? Does this have to do with inner classes? - METHOD: Scope is for each method
Now though, how limits and values come into scope? For example:
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>80%</minimum>
</limit>
can I replace LINE
with INSTRUCTION
for example? And if yes, what does this mean?
Also from the docs:
If a limit refers to a ratio it must be in the range from 0.0 to 1.0 where the number of decimal places will also determine the precision in error messages.
RATIO
vs COUNT
is clear, but can I use them interchangeably? i.e:
<limit>
<counter>LINE</counter>
<value>TOTALCOUNT</value>
<minimum>3</minimum>
</limit>
and if yes, what does the above rule mean?
From a generated report, INSTRUCTION
and BRANCH
are always on ratio