• Software Testing Dictionary
  • Home

Software Testing - Branch Testing



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

Output

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.

Features of Branch Testing

The features of branch testing are listed below −

  • It verifies every branch in the code.
  • It is a non-functional type of testing.
  • It identifies all the probable branches in the code which may produce defects in the software.
  • It gives a clear view of the code coverage.
  • It forms a critical part of software testing and guarantees its reliability, robustness and correctness.
  • By checking all possible branches in the code, it gives a detailed analysis of all the characteristics of the software under multiple conditions.
  • It helps to meet the necessary software quality assurances.
  • It assists in getting better code readability.
  • In industries, which need to adhere to a lot of strict regulations, standards, and practices, the branch testing gives the confidence that the code has been tested thoroughly.
  • It helps to reduce regression errors in the software.
  • It is mostly adopted for safety critical, and health care systems, for example autonomous vehicles, medical devices, flight systems, aerospace, and automotive industries.
  • It is also adopted for finance,banking, e-commerce, and retail software.
  • It is also conducted for gaming and entertainment software.

Advantages of Branch Testing

The advantages of branch testing are listed below −

  • It can be implemented very easily.
  • It confirms every branch in the code has been tested at least once.
  • It verifies that none of the branches in the code has some problematic logic.
  • It also helps to fix errors encountered while performing the statement coverage testing.

Disadvantages of Branch Testing

The disadvantages of branch testing are listed below −

  • It sometimes misses the branches which are inside the boolean expressions.
  • It is an expensive approach.
  • It takes time for implementation.

How to Perform Branch Testing?

The branch testing is performed by following the steps listed below −

Step 1 − Detection of all decision points in the code.

Step 2 − Creation of test cases around the decision points covering both the potential outcomes, namely True and False.

Step 3 − Execution of test cases are done against the code and the testing tools, and frameworks used detect which branches are traversed and which are missed.

Step 4 − Analysis of branch coverage is done where the testing tools generate a percentage of branch coverage of all branches that are covered during execution.

Step 5 − Review of the branch coverage report is done by the developers to find out which all branches are not covered and will require additional testing in future.

Step 6 − Retesting includes execution of all the test cases in addition to the new test cases covering the uncovered branches.

Step 7 − Test closure and reporting is done to infer if all the branches are covered or a desired percentage of coverage is achieved. It all points to completion of the branch testing phase.

Step 8 − Evaluation and decision making of the coverage report is done by the developers, and the quality assurance team to get an idea if the software is ready to be released. Higher branch coverage percentage indicates the maximum paths have been tested and there is a lower probability of getting more bugs.

Conclusion

This concludes our comprehensive take on the tutorial on Software Branch Testing. We’ve started with describing what is branch testing, what are the features of branch testing, what are the advantages of branch testing, what are the disadvantages of branch testing, and how to perform branch testing. This equips you with in-depth knowledge of Software Branch Testing. It is wise to keep practicing what you’ve learned and exploring others relevant to Software Testing to deepen your understanding and expand your horizons.

Advertisements