我知道行覆盖率和分支覆盖率有什么区别,但是代码覆盖率和行覆盖率有什么区别?是以前的指令覆盖吗?
问问题
20275 次
2 回答
44
覆盖率是线路和分支覆盖率的微妙混合;-)。
您可以在我们的指标描述页面上找到公式:
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)
于 2012-07-19T14:05:04.547 回答
3
要扩展答案,您只能查询声纳以获取以下术语:
- conditions_to_cover
- 未覆盖的条件
- lines_to_cover
- 未覆盖线
然后您可以使用以下等式转换为上述术语:
CT + CF = conditions_to_cover - uncovered_conditions
2*B = conditions_to_cover
LC = lines_to_cover - uncovered_lines
EL = lines_to_cover
您可以使用 Sonar Drilldown 或 REST API 来获取上述指标值:
http://my.sonar.com/drilldown/measures/My-Project-Name?metric=line_coverage
http://my.sonar.com/api/resources?resource=55555&metrics=ncloc,conditions_to_cover,uncovered_conditions,lines_to_cover,uncovered_lines,coverage,line_coverage,branch_coverage,it_conditions_to_cover,it_uncovered_conditions,it_lines_to_cover,it_uncovered_lines,it_coverage,it_line_coverage,it_branch_coverage,overall_conditions_to_cover,overall_uncovered_conditions,overall_lines_to_cover,overall_uncovered_lines,overall_coverage,overall_line_coverage,overall_branch_coverage
这篇博文有更多信息:http ://sizustech.blogspot.com/2015/10/making-sense-of-sonar-qube-stats-like.html
于 2015-10-10T01:17:38.470 回答