Sonar-Overall Coverage

拈花ヽ惹草 提交于 2019-11-30 15:28:59

问题


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.


回答1:


From Sonar's documentation:

It is a mix of Line coverage and Condition coverage. Its goal is to provide an even more accurate answer to the following question: How much of the source code has been covered by the unit tests?

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)

Source: https://docs.sonarqube.org/display/SONAR/Metric+Definitions#MetricDefinitions-Tests




回答2:


Here's how the overall coverage is computed: https://docs.sonarqube.org/display/SONAR/Metric+Definitions#MetricDefinitions-Tests

If branch coverage is lower than line coverage (and thus lower than overall coverage), it means that your unit tests test the main cases but not really the corner cases.



来源:https://stackoverflow.com/questions/19216537/sonar-overall-coverage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!