• Software Testing Dictionary
  • Home

Branch Testing


Advertisements

What is Branch Testing?

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 and thereby ensuring that all reachable code is executed.

That is, every branch taken each way, true and false. It helps in validating all the branches in the code making sure that no branch leads to abnormal behavior of the application.

Formula:

Branch Testing = (Number of decisions outcomes tested / Total Number of decision Outcomes) x 100 %

Example:

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

The above logic can be represented by a flowchart as:

Branch Testing in Test Life Cycle

Result :

To calculate Branch  Coverage, one has to 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 Branch Coverage is 2.
Advertisements