Hello,
I’m trying to understand how exactly coverage metrics is calculated.
As described here Metric Definitions | SonarQube Docs
there is a formula:
Coverage = (CT + CF + LC)/(2*B + EL)
where
- CT = conditions that have been evaluated to ‘true’ at least once
- CF = conditions that have been evaluated to ‘false’ at least once
- LC = covered lines = lines to cover - uncovered_lines
- B = total number of conditions
- EL = total number of executable lines (
lines_to_cover
)
I have a java class covered by tests, here are the numbers:
Coverage: 69.2%
Lines to Cover: 22
Uncovered Lines: 8
Line Coverage: 63.6%
Conditions to Cover: 4
Uncovered Conditions: 0
Condition Coverage: 100%
As far as I understand this correctly, it must be equal to 73.3% (4+4+14/2*4+22)
Can someone explain me how coverage ended up with number of 69.2% ?