Tuesday, January 20, 2015

What is difference between Statement coverage and Branch coverage in White box Testing

This is most confusing terminology in white box testing :

Decision coverage    :      

Decision coverage or Branch coverage is a testing method, which aims to ensure that each one of the possible branch from each decision point is executed at least once. 


Example 
Read A
Read B 
IF A+B > 10 THEN 
  Print "A+B is Large" 
ENDIF 
If A > 5 THEN 
  Print "A Large"
ENDIF


Create the flow chart on the basis of above program 


Calculate Branch  Coverage:

find out the minimum number of paths which will ensure that all the edges are covered. In this case there is no single path which will ensure coverage of  all the edges at once. The aim is to cover all possible true/false decisions.
(1) 1A-2C-3D-E-4G-5H
(2) 1A-2B-E-4F
Hence Decision or Branch Coverage is 2.



 Statement Coverage: (take a reference of the same example )

To calculate Statement Coverage, find out the shortest number of paths following
which all the nodes will be covered
Here by traversing through path 1A-2C-3D-E-4G-5H all the nodes are covered. So by traveling through only one path all the nodes are covered.
so the Statement coverage  is 1