path testing and branch testing

18,743

Solution 1

Quick Summary

Summarized from https://www.cs.drexel.edu/~jhk39/teaching/cs576su06/L4.pdf

Path Testing:

  • 100% path coverage.
  • Execute all possible control flow paths through the program.

Statement Testing:

  • 100% statement coverage.
  • Execute all statements in a program at least once under some test.

Branch Testing:

  • 100% branch coverage.
  • Execute enough tests to assure that every branch alternative has been exercised at least once under some test.

In general Path Testing >= Branch Testing >= Statement Testing, in terms of how much confidence they can provide in the correctness of your system.

Discussion

Path coverage counts the number of full paths from input to output through a program that get executed, whereas branch coverage counts the number of branches that were tested at any point in time. In this definition full path coverage will lead to full branch coverage.

There may be multiple paths which hit a single conditional statement, and full path coverage may test the different variants (because inside the if statement an external resource may be invoked which branch coverage would not identify). Branch coverage is more like testing that the branch is hit at some point, and the argument is passed to a mock external resource correctly (not necessarily what comes afterwards).

As seen here: https://www.cs.drexel.edu/~jhk39/teaching/cs576su06/L4.pdf, we can sometimes represent the set of all paths by flow diagrams and the goal is to verify that each path from start to end works as expected in path testing.

Branch Testing Additional Notes

From here: Branch testing

Testing in which all branches in the program source code are tested at least once

Path Testing Additional Notes

From here: http://www.qualitytesting.info/forum/topics/what-is-difference-between-2 and http://www.cs.st-andrews.ac.uk/~ifs/Books/SE9/Web/Testing/PathTest.html

A path is a sequence of executable statements. Testers are concerned with
"entry-exit paths", which begin at the entry point into a given process and
proceed to its exit point. 

The objective of path testing is to ensure that each independent path through
the program is executed at least once. An independent program path is one that
traverses at least one new edge in the flow graph. In program terms, this means
exercising one or more new conditions. Both the true and false branches of all
conditions must be executed.

Solution 2

Basis path testing, a structured testing or white box testing technique used for designing test cases intended to examine all possible paths of execution at least once. Creating and executing tests for all possible paths results in 100% statement coverage and 100% branch coverage.

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.

Share:
18,743

Related videos on Youtube

sasikals26
Author by

sasikals26

Updated on June 04, 2022

Comments

  • sasikals26
    sasikals26 about 2 years

    Can you please explain me the different between Path and Branch testing?

    I read in many articles but still I am confused between this two.

    I searched in stack overflow but I didn't find any suitable answer for this Please help me by providing the link if i am duplicate this question.

    Thanks,

  • yes4me
    yes4me over 7 years
    Statement Testing < Branch Testing < Path Testing
  • ComDubh
    ComDubh over 5 years
    Basis path testing is about covering all linearly independent paths through the method under test.