How to calculate the coverage

Hi every one ,
if this how to calculate the coverage :
coverage = (CT + CF + LC)/(2*B + EL)`

  • 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 )
    how we get the : B ,CT, CF please ?

I have always 0 for all my components(projects) and apparently it’s not automatically calculatedly sonar.

Thanks for your answers .
best regards

Code coverage is not added with Automatic Analysis. You need to use the sonar-scanner to include the test coverage reports during a manual analysis (typically in CI)

thank you but I don’t know how to create the coverage report to pass it to sonar-scanner in order to get all the informations on the view web page .

what language & test framework are you using? the test framework is responsible for creating a coverage report, and sonar-scanner just expects the report file to be saved to the specified location, then it can do the work to display it on the web page

I’m using C++ and google test framework

here’s some links to help you along:

1 Like

thank you very much.