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.
In branch coverage, all conditions must be executed at least once. On the other hand, in condition coverage, all possible outcomes of all conditions must be tested at least once.
No, it does not.
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?' .
Branch coverage is a requirement that, for each branch in the program (e.g., if statements, loops), each branch have been executed at least once during testing. (It is sometimes also described as saying that each branch condition must have been true at least once and false at least once during testing.)
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With