Blog

What is the difference between Path Coverage and Branch Coverage? (ISTQB)

To explain this I’m going to do 2 things.

First I’m going to use an analogy to try and make this situation more ‘real-world’.

Second I’m going to draw a diagram and elaborate from there.

  
So let’s use the example of walking from ‘Hunting and Fishing Westgate’ (Point A) to the traffic light on the yellow road on the top of the screen (Point B).
To achieve Path coverage you need to explore every possible route that you could take to get from ‘Hunting and Fishing Westgate’ to ‘Traffic Light on the Yellow road’.
Here’s what you could do:
  • From H&F Westgate you could turn left then left again onto Fernhill Drive and walk straight until you reach the Traffic light.
  • You could turn right then right again onto Pinot Lane then turn onto Cellar Crescent then turn right onto the yellow road, keep going straight until you reach the traffic light.
  • You could turn right then right again onto Pinot Lane then turn right until you reach the end of the road (at Fernhill Drive) then turn left and keep walking until you reach the traffic light.
And so on and so forth.
My point is, for Path coverage your goal is to take as many different possible routes from Hunting and Fishing Westgate to the Traffic Light
To achieve Branch Coverage, you want to make sure you walk along each road at least once when you walk from Hunting and Fishing Westgate to the traffic light.
There are 4 routes from Points A to B to ensure 100% branch coverage.
  1. On Monday you could turn left then left again onto Fernhill Drive and walk straight until you reach the Traffic light
  1. On Tuesday you could turn right then right again onto Pinot Lane then turn right until you reach the end of the road (at Fernhill Drive) then turn left and keep walking until you reach the traffic light.
  1. On Wednesday you could turn right then right again onto Pinot Lane then turn onto Cellar Crescent then turn right onto the yellow road, keep going straight until you reach the traffic light.
  1. And on Thursday you could turn right then right again onto Pinot Lane then turn right until you reach Asti Lane, turn left onto Asti Lane then turn right once you reach the yellow road and keep walking til you reach the traffic light.
Now using 2 pictures I just drew using Paint, I’m going to attempt to explain the difference between Branch and Path Coverage.
Here’s my first diagram which shows 100% Branch coverage, note that each branch has a colourful line drawn over it at least once.
Now here’s my second diagram which shows 100% Path coverage.

Note that in the first Paint picture, my aim was to make sure that each branch (black line) had a colourful line drawn over it at least once. I.e. each branch had to be covered at least once –>achieving 100% Branch Coverage.

In the second Paint picture, my aim was to explore as many different possible routes to get from the green box at the top to a yellow circle at the bottom.

The second picture is the same as the first picture with the addition of 4 orange lines.

So how did you find this post? Let me know if it helps you tell the difference between Branch Coverage and Path Coverage.Do you prefer my analogy explanation or the pictures I created using Paint?



<!–[endif]–>
 

Comments are closed.


Looking for something?

Use the form below to search the site:


Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!