Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between code coverage and line coverage in sonar

I know what the difference is between line and branch coverage, but what is the difference between code coverage and line coverage? Is the former instruction coverage?

like image 990
Bartosz Radaczyński Avatar asked Jul 19 '12 13:07

Bartosz Radaczyński


People also ask

What is line coverage in SonarQube?

SonarQube measures code quality based on different metrics. The most important metric is the code coverage metric. In this case, no tests have been written, which means you have no code coverage. The cool thing about SonarQube is that it indicates the number of lines that aren't covered by tests.

What is line coverage in code coverage?

Line coverage reports on the execution footprint of testing in terms of which lines of code were executed to complete the test. Edge coverage reports which branches or code decision points were executed to complete the test. They both report a coverage metric, measured as a percentage.

How do I improve sonar code coverage?

to increase your code coverage, the suggestion is to write tests. It can be unit tests (easiest way) or other tests (Integration test, System tests) which may contribute to coverage when a tool can report coverage for these.

What is the point of code coverage?

Code coverage is a metric that can help you understand how much of your source is tested. It's a very useful metric that can help you assess the quality of your test suite, and we will see here how you can get started with your projects.


1 Answers

Coverage is a subtle ;-) mix of the line and the branch coverage.

You can find the formula on our metric description page:

coverage = (CT + CF + LC)/(2*B + EL)  where  CT - branches that evaluated to "true" at least once CF - branches that evaluated to "false" at least once LC - lines covered (lines_to_cover - uncovered_lines)  B - total number of branches (2*B = conditions_to_cover) EL - total number of executable lines (lines_to_cover) 
like image 175
Fabrice - SonarSource Team Avatar answered Oct 02 '22 17:10

Fabrice - SonarSource Team