7

Sonar gives a value of Overall coverage which is a combination of line and branch coverage. I am not sure how important is this metric. What does the value of overall coverage signifies? How it is better than line and branch coverage? Any suggestions would be helpful.

4

2 回答 2

5

从声纳的文档中:

它是线路覆盖和条件覆盖的混合。它的目标是为以下问题提供更准确的答案:单元测试覆盖了多少源代码?

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)

资料来源:https ://docs.sonarqube.org/display/SONAR/Metric+Definitions#MetricDefinitions-Tests

于 2015-02-23T09:49:52.437 回答
2

以下是计算整体覆盖率的方法:https ://docs.sonarqube.org/display/SONAR/Metric+Definitions#MetricDefinitions-Tests

如果分支覆盖率低于行覆盖率(因此低于整体覆盖率),则意味着您的单元测试测试了主要案例,但实际上并未测试角落案例。

于 2013-10-07T09:28:07.267 回答