Loading

Condition Coverage vs Branch Coverage vs Decision Coverage


Condition Coverage:

>This technique aims to cover the various conditions and its consecutive flow. A condition or predicate when evaluates to true must execute the next relevant line of code that follows. This can be explained with the help of an example.

if(a=2)

print "execute this line";

else

print "executing else statement";

end if;

The above pseudocode checks the if condition, if it evaluates to be true, the next statement should execute else the print statement inside else. Ideally this flow is normal, if there is any deviation in this, that must be identified using test cases.

Decision/Branch Coverage:

Branch Coverage technique involves checking whether every possible path or branch is covered. Branching is actually a jump from one decision point to another. The concept can be further elucidated with the help of an example.

Read a

Read a

if a>b

print "a is largest"

else

if a==b

print "Both a and b are equivalent"

else

print "b is largest number"

end if

Conclusion:

If the first condition evaluates to true then the first print statement is printed, if the first becomes false the program must jump to the second else if and print the statement under that. Branch coverage is simply checking a decision point and moving further accordingly, from one decision point to another, whichever relevant. Branch coverage is often calculate using the following formulae -

Branch Testing = (number of decision outcomes tested/total number of decision outcomes)*100

Summary:

Coverage technique offers a way to verify the various points at which a program may tend to behave abnormally or simply terminate. These coverage techniques also helps us to measure to what extent our program is successfully running and how is it handling errors, if any.

Therefore coverage techniques are a great way to analyse and present the functioning of program in the light of specifications.