Sunday, 20 May 2012

How to calculate Statement, Branch/Decision and Path Coverage

Statement Coverage:
In this the test case is executed in such a way that every statement of the code is executed at least once.
Branch/Decision Coverage:
Test coverage criteria requires enough test cases such that each condition in a decision takes on all possible outcomes at least once, and each point of entry to a program or subroutine is invoked at least once. That is, every branch (decision) 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.
Path Coverage:
In this the test case is executed in such a way that every path is executed at least once. All possible control paths taken, including all loop paths taken zero, once, and multiple (ideally, maximum) items in path coverage technique, the test cases are prepared based on the logical complexity measure of a procedural design. In this type of testing every statement in the program is guaranteed to be executed at least one time. Flow Graph, Cyclomatic Complexity and Graph Metrics are used to arrive at basis path.
How to calculate Statement Coverage, Branch Coverage and Path Coverage?
Draw the flow in the following way-
·        Nodes represent entries, exits, decisions and each statement of code.
·        Edges represent non-branching and branching links between nodes.
Read P
Read Q
IF P+Q > 100 THEN
Print “Large”
If P > 50 THEN
Print “P Large”
Calculate statement coverage, branch coverage and path coverage.

The flow chart is-

Statement Coverage (SC):
To calculate Statement Coverage, find out the shortest number of paths following which all the nodes will be covered. Here by traversing through path 1A-2C-3D-E-4G-5H all the nodes are covered. So by traveling through only one path all the nodes 12345 are covered, so the Statement coverage in this case is 1.
Branch Coverage (BC):
To calculate Branch Coverage, find out the minimum number of paths which will ensure covering of all the edges. In this case there is no single path which will ensure coverage of all the edges at one go. By following paths 1A-2C-3D-E-4G-5H, maximum numbers of edges (A, C, D, E, G and H) are covered but edges B and F are left. To covers these edges we can follow 1A-2B-E-4F. By the combining the above two paths we can ensure of traveling through all the paths. Hence Branch Coverage is 2. The aim is to cover all possible true/false decisions.
Path Coverage (PC):
Path Coverage ensures covering of all the paths from start to end.
All possible paths are-
So path coverage is 4.
Thus for the above example SC=1, BC=2 and PC=4.


At 9 March 2016 at 04:05 , Blogger kathickanitha55 said...

Such as very good information,
Thank goodness someone is promoting quality content.these information was more effective information.It's very useful in my studies.
ios training in chennai

At 23 May 2016 at 00:44 , Blogger Camellia Canan said...

These provided information was really so nice,thanks for giving that post and the more skills to develop after refer that post. Your articles really impressed for me,because of all information so nice.

SAP training in Chennai

At 27 May 2016 at 08:18 , Blogger Camellia Canan said...

I have been following you for a couple of months now but this is my first time commenting on a blog post. Thank you for sharing your knowledge and experience with us. Keep up the good work. Already bookmarked for future reference.

SAP training in Chennai

At 17 July 2016 at 23:39 , Blogger Aashi siva said...

I do believe all of the concepts you’ve introduced in your post. They’re very convincing and will definitely work. Nonetheless, the posts are too short for novices. May you please extend them a bit from subsequent time? Thank you for the post.

Online Training in Chennai

At 29 July 2016 at 00:30 , Blogger Suseela Susiee said...

This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.

Digital Marketing Company in Chennai

Digital Marketing Services in Chennai

At 10 August 2016 at 05:26 , Anonymous Anonymous said...

Provides great information about the concept.It helps an individual to gain knowledge on new techniques.Keep on giving this type of information.
Dot net Training in Chennai

At 22 August 2016 at 04:52 , Blogger Geetha said...

Provides great information about the concept.It helps an individual to gain knowledge on new techniques.Keep on giving this type of information.
SEO training in Chennai

At 17 January 2017 at 23:30 , Blogger Shalini said...

Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your.
Digital Marketing Company in India

At 10 March 2017 at 04:43 , Blogger hari andro said...

I am regular visitor of this blog .I am working as blog reviewer in a private press and I saw many useful posts here. Sure, I will give best ratings for this blog .Keep posting best posts like this to get top reviews and ratings from blog reviewers and people .And I am thankful for this valuable post.
Marine Colleges in Chennai | Mechanical Colleges in Chennai | ECE Colleges in Chennai

At 27 June 2017 at 04:35 , Blogger Karthi Keyan said...

very very amazing explaintion....many things gather about yourself...yes realy i enjoy it
Digital Marketing company

in Chennai


Post a Comment

thank you for your comment

Subscribe to Post Comments [Atom]

<< Home