Reputation: 333
SonarQube describes the "Condition" coverage like this:
On each line of code containing some boolean expressions, the condition coverage simply answers the following question: 'Has each boolean expression been evaluated both to true and false?'. This is the density of possible branches in flow control structures that have been followed during unit tests execution.
http://docs.codehaus.org/display/SONAR/Metric+definitions
Well but I suspect they mean "branch coverage":
if (A || B || C)
Testing A=true and B=true yields 100%, without the need of checking the last expression (C). Also just two branches are tested - true and false for the whole expression, not individual expressions. Is that right?
As far as I know, condition coverage should check all conditions in an expression.
Upvotes: 9
Views: 31155
Reputation: 11920
For me on SonarQube 5.6 condition coverage is really the same as path coverage as defined e.g. here: http://www.onjava.com/pub/a/onjava/2007/03/02/statement-branch-and-path-coverage-testing-in-java.html?page=2
For example, my test report points out that on an if-condition that checks two boolean flags, it insists that all 4 possible combinations have to be checked before 100% coverage is attained.
Upvotes: 3
Reputation: 3983
You can read the following thread of discussion: http://sonarqube.15.x6.nabble.com/I-can-t-understand-the-meaning-of-quot-condition-coverage-quot-in-SonarQube-tt5029339.html
Upvotes: 4