A difference between statement and decision coverage

If the tests have complete branch coverage then we can say it also has complete statement coverage, but not the vice versa.

100% branch coverage => 100% statement coverage

100% statement coverage does not imply 100% branch coverage

the reason is in branch coverage apart from executing all the statements, we should also verify if the tests executes all branches, which can be interpreted as covering all edges in the control flow branch

if(a){
   if(b){
     bool statement1 = true;
   }
}

a = true, b = true will give 100% statement coverage, but not branch coverage

enter image description here

In the branch coverage we need to cover all the edges, which we missed in the statement coverage shown as red lines in the above image

Leave a Comment